Class: MiGA::Cli::Action::Ln

Inherits:
MiGA::Cli::Action show all
Defined in:
lib/miga/cli/action/ln.rb

Instance Attribute Summary

Attributes inherited from MiGA::Cli::Action

#cli

Instance Method Summary collapse

Methods inherited from MiGA::Cli::Action

#complete, #empty_action, #initialize, #launch, load, #name

Constructor Details

This class inherits a constructor from MiGA::Cli::Action

Instance Method Details

#parse_cliObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/miga/cli/action/ln.rb', line 7

def parse_cli
  cli.defaults = { info: false, force: false, method: :hardlink }
  cli.parse do |opt|
    cli.opt_object(opt, [:project, :dataset_opt])
    opt.on(
      '-Q', '--project-target PATH',
      '(Mandatory) Path to the project where to link the dataset'
    ) { |v| cli[:project2] = v }
    opt.on(
      '-f', '--force',
      'Force linking, even if dataset\'s preprocessing is incomplete'
    ) { |v| cli[:force] = v }
    opt.on(
      '-s', '--symlink',
      'Create symlinks instead of the default hard links'
    ) { cli[:method] = :symlink }
    opt.on(
      '-c', '--copy',
      'Create copies instead of the default hard links'
    ) { cli[:method] = :copy }
    cli.opt_filter_datasets(opt)
  end
end

#performObject



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/miga/cli/action/ln.rb', line 31

def perform
  p = cli.load_project
  q = cli.load_project(:project2, '-Q')
  ds = cli.load_and_filter_datasets
  ds.each do |d|
    next unless cli[:force] or d.done_preprocessing?

    cli.puts d.name
    q.import_dataset(d, cli[:method])
  end
end