Class: WhyClasses::CLI
- Inherits:
-
Object
- Object
- WhyClasses::CLI
- Defined in:
- lib/why_classes/cli.rb
Overview
Command-line entry point. Parses ARGV into Options, runs, returns an exit code.
Constant Summary collapse
- VALID_FORMATS =
%w[progress clang json diff].freeze
- VALID_FAIL_LEVELS =
%w[none convention warning].freeze
Instance Method Summary collapse
-
#initialize(argv, io: $stdout, err: $stderr) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize(argv, io: $stdout, err: $stderr) ⇒ CLI
Returns a new instance of CLI.
15 16 17 18 19 |
# File 'lib/why_classes/cli.rb', line 15 def initialize(argv, io: $stdout, err: $stderr) @argv = argv @io = io @err = err end |
Instance Method Details
#run ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/why_classes/cli.rb', line 21 def run overrides = return @early_exit if @early_exit = Options.defaults(**overrides, paths: @argv) Runner.new().run(io: @io) rescue OptionParser::ParseError => e @err.puts "why-classes: #{e.}" 2 rescue StandardError => e @err.puts "why-classes: #{e.class}: #{e.}" 2 end |