Class: RubyLens::CLI
- Inherits:
-
Object
- Object
- RubyLens::CLI
- Defined in:
- lib/rubylens/cli.rb
Instance Method Summary collapse
-
#initialize(stdout: $stdout, stderr: $stderr, report_generator: RubyLens.method(:generate_report), showcase_generator: RubyLens.method(:generate_showcase)) ⇒ CLI
constructor
A new instance of CLI.
- #run(arguments) ⇒ Object
Constructor Details
#initialize(stdout: $stdout, stderr: $stderr, report_generator: RubyLens.method(:generate_report), showcase_generator: RubyLens.method(:generate_showcase)) ⇒ CLI
Returns a new instance of CLI.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rubylens/cli.rb', line 8 def initialize( stdout: $stdout, stderr: $stderr, report_generator: RubyLens.method(:generate_report), showcase_generator: RubyLens.method(:generate_showcase) ) @stdout = stdout @stderr = stderr @report_generator = report_generator @showcase_generator = showcase_generator end |
Instance Method Details
#run(arguments) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rubylens/cli.rb', line 20 def run(arguments) arguments = arguments.dup command = arguments.shift return print_version if %w[-v --version version].include?(command) return print_help(0) if command.nil? || %w[-h --help help].include?(command) return generate_report(arguments) if command == "report" return generate_showcase(arguments) if command == "showcase" @stderr.puts "Unknown command: #{command}" print_help(2) rescue OptionParser::ParseError, Error, Errno::ENOENT => error @stderr.puts "rubylens: #{error.}" 2 end |