Class: Apiary::CLI
- Inherits:
-
Object
- Object
- Apiary::CLI
- Defined in:
- lib/apiary/cli.rb
Instance Attribute Summary (collapse)
-
- (Object) command
readonly
Returns the value of attribute command.
Instance Method Summary (collapse)
-
- (CLI) initialize(args)
constructor
A new instance of CLI.
- - (Object) parse_options!(args)
- - (Object) run(args, options)
Constructor Details
- (CLI) initialize(args)
A new instance of CLI
9 10 11 12 |
# File 'lib/apiary/cli.rb', line 9 def initialize(args) = (args) run(args, ) end |
Instance Attribute Details
- (Object) command (readonly)
Returns the value of attribute command
7 8 9 |
# File 'lib/apiary/cli.rb', line 7 def command @command end |
Instance Method Details
- (Object) parse_options!(args)
20 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 57 58 59 60 |
# File 'lib/apiary/cli.rb', line 20 def (args) @command = nil = {} = OptionParser.new do |opts| opts.on("--path [PATH]") do |path| [:apib_path] = path end opts.on("--api_host API_HOST") do |api_host| [:api_host] = api_host end opts.on("--browser BROWSER") do |browser| [:browser] = browser end opts.on("--server") do [:server] = true end opts.on("--port [PORT]") do |port| [:port] = port end opts.on('-v', '--version') do @command = :version end opts.on( '-h', '--help') do @command = :help end end .parse! rescue OptionParser::InvalidOption => e puts e puts Apiary::Command::Help. exit 1 end |
- (Object) run(args, options)
14 15 16 17 18 |
# File 'lib/apiary/cli.rb', line 14 def run(args, ) command = args.first command = @command if @command Apiary::Command::Runner.run(command, ) end |