Module: Kajiki
- Defined in:
- lib/kajiki.rb,
lib/kajiki/runner.rb,
lib/kajiki/handler.rb,
lib/kajiki/presets.rb
Defined Under Namespace
Modules: Handler Classes: Runner
Constant Summary collapse
- SUB_COMMANDS =
Available commands.
%w(start stop)
- OPT_DESCS =
Description strings for help display.
{ banner: "Usage: #{File.basename($0)} [options] {#{SUB_COMMANDS.join('|')}}", address: 'Bind to address', daemonize: 'Run in the background', error: 'Output error to file', group: 'Group to run as', log: 'Log output to file', pid: 'Store PID to file', port: 'Use port', user: 'User to run as' }
Class Method Summary collapse
-
.preset_options(preset) ⇒ Object
Preset options for command-line parsing.
- .run(opts, &block) ⇒ Object
Class Method Details
.preset_options(preset) ⇒ Object
Preset options for command-line parsing.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/kajiki/presets.rb', line 21 def self.(preset) case preset when :minimal Trollop. do OPT_DESCS[:banner] opt :daemonize, OPT_DESCS[:daemonize] opt :pid, OPT_DESCS[:pid], type: :string end when :simple Trollop. do OPT_DESCS[:banner] opt :daemonize, OPT_DESCS[:daemonize] opt :error, OPT_DESCS[:error], type: :string opt :group, OPT_DESCS[:group], type: :string opt :log, OPT_DESCS[:log], type: :string opt :pid, OPT_DESCS[:pid], type: :string opt :user, OPT_DESCS[:user], type: :string depends(:user, :group) end when :server Trollop. do OPT_DESCS[:banner] opt :address, OPT_DESCS[:address], default: '0.0.0.0' opt :daemonize, OPT_DESCS[:daemonize] opt :error, OPT_DESCS[:error], type: :string opt :group, OPT_DESCS[:group], type: :string opt :log, OPT_DESCS[:log], type: :string opt :pid, OPT_DESCS[:pid], short: 'P', type: :string opt :port, OPT_DESCS[:port], default: 4567 opt :user, OPT_DESCS[:user], type: :string depends(:user, :group) end else fail 'Invalid preset option.' end end |