def handle_options
ARGV.options do |opt|
opt.banner = "#{MYNAME} - view and (selectively) print PDF and PostScript"
opt.separator ''
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',
'printer is doublesided') do |v| @doublesided = true end
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-]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.on('-h','--help',
'print this help and exit') \
do quit(opt.help) end
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( '--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
@printer = "-P#{@printer}" if @printer
end