Class: PointmdComments::OptParser
- Inherits:
-
Object
- Object
- PointmdComments::OptParser
- Defined in:
- lib/pointmd_comments/opt_parser.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize ⇒ OptParser
constructor
A new instance of OptParser.
-
#parse ⇒ Object
rubocop:disable Metrics/MethodLength, Metrics/AbcSize.
Constructor Details
#initialize ⇒ OptParser
Returns a new instance of OptParser.
8 9 10 |
# File 'lib/pointmd_comments/opt_parser.rb', line 8 def initialize @options = {} end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/pointmd_comments/opt_parser.rb', line 6 def @options end |
Instance Method Details
#parse ⇒ Object
rubocop:disable Metrics/MethodLength, Metrics/AbcSize
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 |
# File 'lib/pointmd_comments/opt_parser.rb', line 13 def parse OptionParser.new do |opts| opts. = 'Usage: pointmd_comments [options]' opts.on('-v', '--verbose', 'Show logs and backtraces') do |v| [:verbose] = v end opts.on( '-sSOURCE', '--source=SOURCE', "A source to pull links from. Available sources are: #{Aggregators::Posts::ALLOWED_SOURCES}" ) do |s| [:source] = s.to_sym end opts.on( '-o OUTPUT_PATH', '--output=OUTPUT_PATH', 'A custom file path for the CSV.' ) do |p| [:output] = p end opts.on('-V', '--version', 'Version') do puts PointmdComments::VERSION exit end end.parse! set_default_source unless [:source] && [:path] validate_source end |