Class: GemXray::CLI
- Inherits:
-
Object
- Object
- GemXray::CLI
- Defined in:
- lib/gemxray/cli.rb
Constant Summary collapse
- HelpRequested =
Class.new(StandardError)
- COMMANDS =
%w[scan clean pr licenses init version help].freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv, out:, err:, stdin:) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize(argv, out:, err:, stdin:) ⇒ CLI
Returns a new instance of CLI.
14 15 16 17 18 19 |
# File 'lib/gemxray/cli.rb', line 14 def initialize(argv, out:, err:, stdin:) @argv = argv.dup @out = out @err = err @stdin = stdin end |
Class Method Details
.start(argv = ARGV, out: $stdout, err: $stderr, stdin: $stdin) ⇒ Object
10 11 12 |
# File 'lib/gemxray/cli.rb', line 10 def self.start(argv = ARGV, out: $stdout, err: $stderr, stdin: $stdin) new(argv, out: out, err: err, stdin: stdin).run end |
Instance Method Details
#run ⇒ Object
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 |
# File 'lib/gemxray/cli.rb', line 21 def run command = extract_command case command when "scan" then run_scan(@argv) when "clean" then run_clean(@argv) when "pr" then run_pr(@argv) when "licenses" then run_list_licenses(@argv) when "init" then run_init(@argv) when "version" out.puts(GemXray::VERSION) 0 else out.puts(help_text) 0 end rescue HelpRequested 0 rescue OptionParser::ParseError => e err.puts(e.) err.puts(help_text) 1 rescue Error => e err.puts("Error: #{e.}") 1 end |