Class: Licensure::CLI
- Inherits:
-
Object
- Object
- Licensure::CLI
- Defined in:
- lib/licensure/cli.rb
Overview
CLI entrypoint and subcommand orchestrator.
Constant Summary collapse
- FORMATS =
%w[table csv json markdown].freeze
Instance Method Summary collapse
-
#initialize(argv = ARGV, output: $stdout, error_output: $stderr, input: $stdin) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Integer
Constructor Details
#initialize(argv = ARGV, output: $stdout, error_output: $stderr, input: $stdin) ⇒ CLI
Returns a new instance of CLI.
14 15 16 17 18 19 |
# File 'lib/licensure/cli.rb', line 14 def initialize(argv = ARGV, output: $stdout, error_output: $stderr, input: $stdin) @argv = argv.dup @output = output @error_output = error_output @input = input end |
Instance Method Details
#run ⇒ Integer
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 |
# File 'lib/licensure/cli.rb', line 22 def run command = @argv.shift case command when nil, "help", "-h", "--help" run_help(@argv.shift) when "list" run_list when "check" run_check when "init" run_init when "version" run_version else @error_output.puts("Unknown command: #{command}") 2 end rescue OptionParser::ParseError, Licensure::Error => e @error_output.puts(e.) 2 rescue StandardError => e @error_output.puts("Unexpected error: #{e.}") @error_output.puts(e.backtrace.join("\n")) 2 end |