Class: Exercism::Rb::CLI
- Inherits:
-
Object
- Object
- Exercism::Rb::CLI
- Defined in:
- lib/exercism/rb/cli.rb
Constant Summary collapse
- COMMANDS =
%w[new edit test irb submit use current path list clear help version].freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv, out: $stdout, err: $stderr) ⇒ CLI
constructor
A new instance of CLI.
- #start ⇒ Object
Constructor Details
#initialize(argv, out: $stdout, err: $stderr) ⇒ CLI
Returns a new instance of CLI.
14 15 16 17 18 19 20 21 22 |
# File 'lib/exercism/rb/cli.rb', line 14 def initialize(argv, out: $stdout, err: $stderr) @argv = argv.dup @ui = UI.new(out: out, err: err) @state = State.new @runner = CommandRunner.new(ui: @ui) @track = Config.track @root = Config.root(@track) @resolver = Resolver.new(state: @state, track: @track, root: @root) end |
Class Method Details
.start(argv, out: $stdout, err: $stderr) ⇒ Object
10 11 12 |
# File 'lib/exercism/rb/cli.rb', line 10 def self.start(argv, out: $stdout, err: $stderr) new(argv, out: out, err: err).start end |
Instance Method Details
#start ⇒ Object
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 |
# File 'lib/exercism/rb/cli.rb', line 24 def start command = @argv.shift || "help" case command when "new" then new_command when "edit" then edit_command when "test" then test_command when "irb" then irb_command when "submit" then submit_command when "use" then use_command when "current" then current_command when "path" then path_command when "list" then list_command when "clear" then clear_command when "help", "-h", "--help" then help_command when "version", "-v", "--version" then version_command else raise Error, "Unknown command: #{command}. Use `xrb help`." end 0 rescue Error => e @ui.error(e.) 1 rescue Interrupt @ui.error("Interrupted.") 130 end |