Module: Mdtoc::CLI
- Extended by:
- T::Sig
- Defined in:
- lib/mdtoc/cli.rb
Defined Under Namespace
Classes: Options
Class Method Summary collapse
Class Method Details
.parse(args) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mdtoc/cli.rb', line 14 def parse(args) parser = OptionParser.new do |parser_| parser_. = "Usage: #{parser_.program_name} [options] files or directories..." parser_.on('-h', '--help', 'Show this message') do puts parser_ exit end parser_.on('-o', '--output PATH', 'Update a table of contents in the file at PATH') parser_.on('-a', '--[no-]append', "Append to the --output file if a <!-- mdtoc --> tag isn't found") parser_.on('-c', '--[no-]create', 'Create the --output file if it does not exist') end = Options.new .paths = parser.parse(args, into: ) if .paths.empty? warn('Specify at least one file or directory to read') exit(1) end end |