26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/mdtoc/cli.rb', line 26
def self.for_args(args)
parser = OptionParser.new do |parser_|
parser_.banner = "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 = Options.new
options.paths = parser.parse(args, into: options)
if options.paths.empty?
warn('Specify at least one file or directory to read')
exit(1)
end
options
end
|