class MiGA::Cli::Action::Ln

Public Instance Methods

parse_cli() click to toggle source
# File lib/miga/cli/action/ln.rb, line 8
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
perform() click to toggle source
# File lib/miga/cli/action/ln.rb, line 32
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