def parse_cli
cli.defaults = { daemon_opts: [], show_log: false }
cli.expect_operation = true
cli.parse do |opt|
opt.separator 'Available operations:'
{
start: 'Start an instance of the application',
stop: 'Start an instance of the application',
run: 'Start the application and stay on top',
status: 'Show status (PID) of application instances'
}.each { |k, v| opt.separator sprintf(' %*s%s', -33, k, v) }
opt.separator ''
opt.separator 'MiGA options:'
cli.opt_object(opt, [:project])
opt.on(
'--shutdown-when-done',
'Exit the daemon when all processing is done',
'Otherwise, it will stay idle awaiting for new data (default)'
) { |v| cli[:shutdown_when_done] = v }
opt.on(
'--latency INT',
'Number of seconds the daemon will be sleeping'
) { |v| cli[:latency] = v.to_i }
opt.on(
'--max-jobs INT',
'Maximum number of jobs to use simultaneously'
) { |v| cli[:maxjobs] = v.to_i }
opt.on(
'--node-list PATH',
'Path to the list of execution hostnames'
) { |v| cli[:nodelist] = v }
opt.on(
'--ppn INT', Integer,
'Maximum number of cores to use in a single job'
) { |v| cli[:ppn] = v }
opt.on(
'--ppn-project INT', Integer,
'Maximum number of cores to use in project-wide tasks'
) { |v| cli[:ppn_project] = v }
opt.on(
'--json PATH',
'Path to a custom daemon definition in json format'
) { |v| cli[:json] = v }
opt.on(
'--show-log',
'Display log on advance instead of the progress summary'
) { |v| cli[:show_log] = v }
cli.opt_common(opt)
opt.separator 'Daemon options:'
opt.on(
'-t', '--ontop',
'Stay on top (does not daemonize)'
) { cli[:daemon_opts] << '-t' }
opt.on(
'-f', '--force',
'Force operation'
) { cli[:daemon_opts] << '-f' }
opt.on(
'-n', '--no_wait',
'Do not wait for processes to stop'
) { cli[:daemon_opts] << '-n' }
opt.on(
'--shush',
'Silence the daemon'
) { cli[:daemon_opts] << '--shush' }
opt.separator ''
end
end