Module: Apiway::Commands

Defined in:
lib/apiway/commands.rb

Constant Summary collapse

HANDLERS =
{
  version:  [ '-v', 'v', 'version'  ],
  server:   [ '-s', 's', 'server'   ],
  generate: [ '-g', 'g', 'generate' ],
  create:   [ '-n', 'n', 'new'      ],
  help:     [ '-h', 'h', 'help'     ]
}
DESC =
{
  version:  'Show gem version',
  server:   'Launch thin server, alias for `bundle exec thin start`',
  generate: 'Launch generator, run `apiway generator help` to show commands of generator',
  create:   'Creating a new application',
  help:     'Show list of commands'
}

Class Method Summary collapse

Class Method Details

.run(command = nil, *args) ⇒ Object



25
26
27
28
29
# File 'lib/apiway/commands.rb', line 25

def run( command = nil, *args )
  return help unless command
  HANDLERS.each { |handler, commands| return send( handler, *args ) if commands.include? command }
  puts "Apiway: Unknown command `#{ args.unshift( command ).join " " }`"
end