module Kajiki

Constants

OPT_DESCS

Description strings for help display.

SUB_COMMANDS

Available commands.

Public Class Methods

preset_options(preset, options = {}) click to toggle source

Preset options for command-line parsing. @param [Symbol] presets are: `:minimal`, `:simple`, or `:server`.

# File lib/kajiki/presets.rb, line 22
def self.preset_options(preset, options = {})
  case preset
  when :minimal
    Optimist.options do
      banner OPT_DESCS[:banner]
      opt :daemonize, OPT_DESCS[:daemonize]
      opt :pid, OPT_DESCS[:pid], type: :string
    end
  when :simple
    Optimist.options do
      banner OPT_DESCS[:banner]
      opt :config, OPT_DESCS[:config], type: :string if options[:config]
      opt :daemonize, OPT_DESCS[:daemonize]
      opt :error, OPT_DESCS[:error], type: :string unless options[:error] == false
      opt :group, OPT_DESCS[:group], type: :string unless options[:user] == false
      opt :log, OPT_DESCS[:log], type: :string
      opt :pid, OPT_DESCS[:pid], type: :string
      opt :user, OPT_DESCS[:user], type: :string unless options[:user] == false
      depends(:user, :group) unless options[:user] == false
    end
  when :server
    Optimist.options do
      banner OPT_DESCS[:banner]
      opt :address, OPT_DESCS[:address], default: '0.0.0.0'
      opt :config, OPT_DESCS[:config], type: :string if options[:config]
      opt :daemonize, OPT_DESCS[:daemonize]
      opt :error, OPT_DESCS[:error], type: :string unless options[:error] == false
      opt :group, OPT_DESCS[:group], type: :string unless options[:user] == false
      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 unless options[:user] == false
      depends(:user, :group) unless options[:user] == false
    end
  else
    fail 'Invalid preset option.'
  end
end
run(opts, &block) click to toggle source
# File lib/kajiki.rb, line 7
def self.run(opts, &block)
  Runner.run(opts, &block)
end