Class: Rubycritic::Cli::Options
- Inherits:
-
Object
- Object
- Rubycritic::Cli::Options
- Defined in:
- lib/rubycritic/cli/options.rb
Instance Method Summary collapse
- #help_text ⇒ Object
-
#initialize(argv) ⇒ Options
constructor
A new instance of Options.
- #parse ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(argv) ⇒ Options
Returns a new instance of Options.
6 7 8 9 |
# File 'lib/rubycritic/cli/options.rb', line 6 def initialize(argv) @argv = argv @parser = OptionParser.new end |
Instance Method Details
#help_text ⇒ Object
34 35 36 |
# File 'lib/rubycritic/cli/options.rb', line 34 def help_text @parser.help end |
#parse ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rubycritic/cli/options.rb', line 11 def parse @parser.new do |opts| opts. = "Usage: rubycritic [options] [paths]" opts.on("-p", "--path [PATH]", "Set path where report will be saved (tmp/rubycritic by default)") do |path| @root = path end opts.on("-m", "--mode-ci", "Use CI mode (faster, but only analyses last commit)") do @mode = :ci end opts.on_tail("-v", "--version", "Show gem's version") do @mode = :version end opts.on_tail("-h", "--help", "Show this message") do @mode = :help end end.parse!(@argv) self end |
#to_h ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/rubycritic/cli/options.rb', line 38 def to_h { :mode => @mode, :root => @root, :paths => paths } end |