Class: Rosette::Client::Cli
- Inherits:
-
Object
- Object
- Rosette::Client::Cli
- Defined in:
- lib/rosette/client/cli.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
-
#terminal ⇒ Object
readonly
Returns the value of attribute terminal.
-
#writer ⇒ Object
readonly
Returns the value of attribute writer.
Instance Method Summary collapse
-
#initialize(terminal, writer, api, repo) ⇒ Cli
constructor
A new instance of Cli.
- #start(argv) ⇒ Object
Constructor Details
#initialize(terminal, writer, api, repo) ⇒ Cli
Returns a new instance of Cli.
11 12 13 14 15 16 |
# File 'lib/rosette/client/cli.rb', line 11 def initialize(terminal, writer, api, repo) @api = api @terminal = terminal @writer = writer @repo = repo end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
9 10 11 |
# File 'lib/rosette/client/cli.rb', line 9 def api @api end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
9 10 11 |
# File 'lib/rosette/client/cli.rb', line 9 def repo @repo end |
#terminal ⇒ Object (readonly)
Returns the value of attribute terminal.
9 10 11 |
# File 'lib/rosette/client/cli.rb', line 9 def terminal @terminal end |
#writer ⇒ Object (readonly)
Returns the value of attribute writer.
9 10 11 |
# File 'lib/rosette/client/cli.rb', line 9 def writer @writer end |
Instance Method Details
#start(argv) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/rosette/client/cli.rb', line 18 def start(argv) if command_const = find_command_const(argv.first) command_const.new(api, terminal, writer, repo, argv[1..-1]).execute else terminal.say("Command '#{argv.first}' not recognized.") end rescue Rosette::Client::ApiError => e terminal.say("An api error occurred: #{e.message}") end |