def parse_cli
cli.defaults = {
database: :recommended,
version: :latest,
local: File.expand_path('.miga_db', ENV['MIGA_HOME']),
host: MiGA::MiGA.known_hosts(:miga_db),
pb: true,
reuse_archive: false,
overwrite: true
}
cli.parse do |opt|
opt.on(
'-n', '--database STRING',
"Name of the database to download. By default: #{cli[:database]}"
) { |v| cli[:database] = v.to_sym }
opt.on(
'--db-version STRING',
"Database version to download. By default: #{cli[:version]}"
) { |v| cli[:version] = v.to_sym }
opt.on(
'-l', '--local-dir PATH',
"Local directory to store the database. By default: #{cli[:local]}"
) { |v| cli[:local] = v }
opt.on(
'--host STRING',
"Remote host of the database. By default: #{cli[:host]}"
) { |v| cli[:host] = v }
opt.on(
'--list',
'List available databases and exit'
) { |v| cli[:list_databases] = v }
opt.on(
'--list-versions',
'List available versions of the database and exit'
) { |v| cli[:list_versions] = v }
opt.on(
'--reuse-archive',
'Reuse a previously downloaded archive if available'
) { |v| cli[:reuse_archive] = v }
opt.on(
'--no-overwrite',
'Exit without downloading if the target database already exists'
) { |v| cli[:overwrite] = v }
opt.on('--no-progress', 'Supress progress bars') { |v| cli[:pb] = v }
end
end