Class: Fastererer::CLI
- Inherits:
-
Object
- Object
- Fastererer::CLI
- Defined in:
- lib/fastererer/cli.rb
Class Method Summary collapse
- .build_parser(options) ⇒ Object
- .execute ⇒ Object
- .parse_options(argv) ⇒ Object
- .show_help_and_exit(opts) ⇒ Object
- .show_version_and_exit ⇒ Object
Class Method Details
.build_parser(options) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/fastererer/cli.rb', line 24 def self.build_parser() OptionParser.new do |opts| opts. = 'Usage: fastererer [options] [path]' opts.on('--no-color', 'Disable ANSI color in output') { [:no_color] = true } opts.on('-h', '--help', 'Show this help') { show_help_and_exit(opts) } opts.on('-v', '--version', 'Show version') { show_version_and_exit } end end |
.execute ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/fastererer/cli.rb', line 10 def self.execute = (ARGV.dup) Painter.disable! if [:no_color] file_traverser = Fastererer::FileTraverser.new([:path]) file_traverser.traverse abort if file_traverser.offenses_found? end |
.parse_options(argv) ⇒ Object
18 19 20 21 22 |
# File 'lib/fastererer/cli.rb', line 18 def self.(argv) = {} [:path] = build_parser().parse(argv).first end |
.show_help_and_exit(opts) ⇒ Object
33 34 35 36 |
# File 'lib/fastererer/cli.rb', line 33 def self.show_help_and_exit(opts) puts opts exit end |
.show_version_and_exit ⇒ Object
38 39 40 41 |
# File 'lib/fastererer/cli.rb', line 38 def self.show_version_and_exit puts Fastererer::VERSION exit end |