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
rubocop:disable Metrics/MethodLength.
- #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
53 54 55 |
# File 'lib/rubycritic/cli/options.rb', line 53 def help_text @parser.help end |
#parse ⇒ Object
rubocop:disable Metrics/MethodLength
12 13 14 15 16 17 18 19 20 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 47 48 49 50 51 |
# File 'lib/rubycritic/cli/options.rb', line 12 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( "-f", "--format [FORMAT]", [:html, :json], "Report smells in the given format:", " html (default)", " json" ) do |format| @format = format end opts.on("-m", "--mode-ci", "Use CI mode (faster, but only analyses last commit)") do @mode = :ci end opts.on("--deduplicate-symlinks", "De-duplicate symlinks based on their final target") do @deduplicate_symlinks = true end opts.on("--suppress-ratings", "Suppress letter ratings") do = true 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
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/rubycritic/cli/options.rb', line 57 def to_h { :mode => @mode, :root => @root, :format => @format, :deduplicate_symlinks => @deduplicate_symlinks, :paths => paths, :suppress_ratings => } end |