def handle_options
ARGV.options do |opt|
opt.banner = "#{MYNAME} - a LaTeX maker"
opt.separator ''
opt.separator "Usage: mk [options] [file]"
opt.separator ''
opt.separator 'mk-specific options:'
opt.on('-C','--Clean',
"Remove all unnecessary files generated by latex and bibtex") \
do @Clean = true end
opt.on('-c','--clean',
"Same, except for the pdf or postscript files") \
do @clean = true end
opt.on( '--ps',
"Generate postscript version of document (default: pdf)") \
do @ps = true end
opt.on( '--[no-]edit[=STRING]',String,
"use STRING as the file to be edited") \
do |v| @edit = v||'' end
opt.on('-w','--[no-]warn',
"After a successful run, print warnings found in the log file") \
do |v| @warn = v end
opt.separator ''
opt.separator 'vpp-related options:'
opt.on('-b','--batch=STRING',String,
'run in batch using STRING for print command') do |v| @batch = v end
opt.on('-p','--printer=STRING',String,
'print to printer named STRING') \
do |v| @printer = v end
opt.on('-d','--doublesided',String,
'printer is doublesided') \
do |v| @doublesided = true end
opt.on( '--[no-]view',
"do [not] view the document") \
do |v| @view = v end
opt.on( '--[no-]print',
"do [not] offer printing interaction") \
do |v| @print = v end
opt.separator ''
opt.separator 'General options:'
opt.on('-r','--rc=STRING', String,
'use STRING as an rc file') \
do |v|
@rc = v
File.exist?(v) or quit("File #{v}, specified with --rc, does not exist",1)
File.readable?(v) or quit("File #{v}, specified with --rc, is not readable",1)
end
opt.on('-V','--version',
'print version and exit') \
do print_version(RELEASE) end
opt.on('-v','--[no-]verbose',
'be [not] verbose (quiet is the default)') \
do |v| @verbose = v end
opt.on( '--[no-]check',
'do [not] check the availability of executables') \
do |v| @check = v end
opt.on('-h','--help',
'print this help and exit') \
do quit(opt.help) end
opt.separator ''
opt.separator 'Defaults: '
opt.separator '--no-warn --print --view --no-verbose --no-check main'
opt.separator ''
opt.separator 'For backward compatibility with Perl version:'
opt.on('-q','--quiet',
'be quiet (quiet is the default)') \
do @verbose = false end
opt.on( '--nocolor',
'no coloring') \
do String.colortype end
opt.on( '--web',
'use html for coloring messages (ansi coloring is the default)') \
do String.colortype(:html); @sep = "<br>\n" end
opt.on( '--noquiet',
'be verbose (quiet is the default)') \
do @verbose = true end
opt.on( '--noview',
"do not view the document") \
do @view = false end
opt.on( '--noprint',
"do not offer printing interaction") \
do @print = false end
opt.parse!
end or quit("Option parsing error",1)
@view, @print = false, true if @batch
end