class MiGA::Cli::Action::Rm

Public Instance Methods

parse_cli() click to toggle source
# File lib/miga/cli/action/rm.rb, line 7
def parse_cli
  cli.defaults = { remove: false }
  cli.parse do |opt|
    cli.opt_object(opt, %[project dataset_opt result_opt])
    opt.on(
      '-R', '--remove',
      'Also remove all associated files',
      'By default, only unlinks from metadata'
    ) { |v| cli[:remove] = v }
  end
end
perform() click to toggle source
# File lib/miga/cli/action/rm.rb, line 19
def perform
  if cli[:result] && r = cli.load_result
    cli[:remove] ? r.remove! : r.unlink
  elsif d = cli.load_dataset
    cli.load_project.unlink_dataset(d.name)
    d.remove! if cli[:remove]
  else
    raise "You must define one of --result or --dataset"
  end
end