Class: SlimLint::Options
- Inherits:
-
Object
- Object
- SlimLint::Options
- Defined in:
- lib/slim_lint/options.rb
Overview
Handles option parsing for the command line application.
Constant Summary collapse
- DEFAULT_FILES =
Path scanned by default when no files or directories are given on the command line.
['.'].freeze
Instance Method Summary collapse
-
#parse(args) ⇒ Hash
Parses command line options into an options hash.
Instance Method Details
#parse(args) ⇒ Hash
Parses command line options into an options hash.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/slim_lint/options.rb', line 16 def parse(args) @options = {} OptionParser.new do |parser| parser. = "Usage: #{APP_NAME} [options] [file1, file2, ...]\n\n" \ 'If no files or directories are given, the current ' \ 'directory is scanned by default.' parser parser parser end.parse!(args) # Any remaining arguments are assumed to be files; fall back to # DEFAULT_FILES when none are given @options[:files] = args.empty? ? DEFAULT_FILES : args @options rescue OptionParser::InvalidOption => e raise Exceptions::InvalidCLIOption, e., e.backtrace end |