def parse_cli
cli.expect_files = true
cli.defaults = { ref: true, ignore_dups: false }
cli.parse do |opt|
opt.separator 'You can create multiple datasets with a single command; ' 'simply pass all the files at the end: {FILES...}'
opt.separator 'If -D is passed, only one dataset will be added. ' 'Otherwise, dataset names will be determined by the file paths (see -R)'
opt.separator ''
cli.opt_object(opt, [:project, :dataset_opt, :dataset_type_req])
opt.on(
'-q', '--query',
'Register the dataset as a query, not a reference dataset'
) { |v| cli[:ref] = !v }
opt.on(
'-d', '--description STRING',
'Description of the dataset'
) { |v| cli[:description] = v }
opt.on(
'-c', '--comments STRING',
'Comments on the dataset'
) { |v| cli[:comments] = v }
opt.on(
'-m', '--metadata STRING',
'Metadata as key-value pairs separated by = and delimited by comma',
'Values are saved as strings except for booleans (true / false) or nil'
) { |v| cli[:metadata] = v }
opt.on(
'-R', '--name-regexp REGEXP', Regexp,
'Regular expression indicating how to extract the name from the path',
'By default for paired files:',
"'#{MiGA::Cli.FILE_REGEXP(true)}'",
'By default for other files:',
"'#{MiGA::Cli.FILE_REGEXP}'"
) { |v| cli[:regexp] = v }
opt.on(
'--prefix STRING',
'Prefix to all the dataset names'
) { |v| cli[:prefix] = v }
opt.on(
'-i', '--input-type STRING',
'Type of input data, one of the following:',
*self.class.INPUT_TYPES.map { |k, v| "~ #{k}: #{v[0]}" }
) { |v| cli[:input_type] = v.downcase.to_sym }
opt.on(
'--ignore-dups',
'Continue with a warning if a dataset already exists'
) { |v| cli[:ignore_dups] = v }
end
end