Method: Mdoc#load_cli_options
- Defined in:
- lib/mdoc/options.rb
#load_cli_options(argv = ARGV) ⇒ Object
load command line options rubocop:disable LineLength, MethodLength
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/mdoc/options.rb', line 36 def (argv = ARGV) load_defaults unless opts argv = %w[-h] if argv.size == 0 OptionParser.new do |opts| opts. = 'Usage: mdoc [options] file.md [file2.md]' opts.separator '' opts.separator 'Options: ' opts.on('-t TPL', '--template TPL', 'output file template') do |tpl| set_option!({ template: tpl }) end opts.on('-o FILE', '--output FILE', 'output file template') do |file| set_option!({ output: file }) end opts.on('-p P,P2', '--processors P,P2', 'enable processors') do |p| p.split(',').each do |pr| @opts.processors << pr unless @opts.processors.include?(pr) end end opts.on('-z P,P2', '--disable P,P2', 'disable processors') do |op| op.split(',').each do |pr| @opts.no_processors << pr unless @opts.processors.include?(pr) end end opts.on('-d D,D2', '--template_directories D,D2', 'directories for finding template') do |d| d.split(',').each do |dir| dir = File.(dir) @opts.tpl_directories << dir unless @opts.tpl_directories.include?(dir) end end opts.on('-O', '--no-output', 'dump result to STDOUT') do @opts.no_output = true end opts.on_tail('-v', '--version', 'show mdoc version') do puts Mdoc::VERSION exit end opts.on_tail('-h', '--help', 'display this screen') do puts opts exit end end.parse!(argv) set_option!({ s_files: argv }) # check consistency for related options raise 'you can not specify output file when there are more than on source files.' if opts.output && opts.s_files.size > 0 raise 'you can not speficy output file with --no-output option' if opts.output && opts.no_output end |