def parse_cli
cli.defaults = { daemon_opts: [] }
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',
list: 'List all daemons and their status',
terminate: 'Terminate all daemons in the lair and exit'
}.each { |k, v| opt.separator sprintf(' %*s%s', -33, k, v) }
opt.separator ''
opt.separator 'MiGA options:'
opt.on(
'-p', '--path PATH',
'(Mandatory) Path to the directory where the MiGA projects are located'
) { |v| cli[:path] = v }
opt.on(
'--exclude NAME1,NAME2,NAME3', Array,
'Exclude these projects (identified by name) from the lair'
) { |v| cli[:exclude] = v }
opt.on(
'--json PATH',
'Path to a custom daemon definition in json format'
) { |v| cli[:json] = v }
opt.on(
'--latency INT', Integer,
'Time to wait between iterations in seconds, by default: 120'
) { |v| cli[:latency] = v }
opt.on(
'--wait-for INT', Integer,
'Time to wait for a daemon to report being alive in seconds',
'by default: 30'
) { |v| cli[:wait_for] = v }
opt.on(
'--keep-inactive',
'If set, daemons are kept alive even when inactive;',
'i.e., when all tasks are complete'
) { |v| cli[:keep_inactive] = v }
opt.on(
'--no-trust-timestamp',
'Check all results instead of trusting project timestamps'
) { |v| cli[:trust_timestamp] = v }
opt.on(
'--name STRING',
'A name for the chief daemon process'
) { |v| cli[:name] = v }
opt.on(
'--dry',
'Report when daemons would be launched, but don\t actually launch them'
) { |v| cli[:dry] = 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