opt.on('-f','overwrite existing outfile (default)'){$opts.delete:nooverwrite_outfile}# without this, optparse autocomplete to --fno-pic and break older scripts...
opt.on('--c','parse source as a C file'){$opts[:srctype]='c'}
opt.on('--asm','parse asm as an ASM file'){$opts[:srctype]='asm'}
opt.on('--stdin','parse source on stdin'){ARGV<<'-'}
opt.on('-v','-W','verbose'){$VERBOSE=true}
opt.on('-d','debug'){$DEBUG=$VERBOSE=true}
opt.on('-D var=val','define a preprocessor macro'){|v|v0,v1=v.split('=',2);$opts[:macros][v0]=v1}
opt.on('--cstring','encode output as a C string'){$opts[:to_string]=:c}
opt.on('--jsstring','encode output as a js string'){$opts[:to_string]=:js}
opt.on('--string','encode output as a string to stdout'){$opts[:to_string]=:inspect}
opt.on('--varname name','the variable name for string output'){|v|$opts[:varname]=v}
opt.on('-e class','--exe class','use a specific ExeFormat class'){|c|$opts[:execlass]=Metasm.const_get(c)}
opt.on('--cpu cpu','use a specific CPU class'){|c|$opts[:cpu]=Metasm.const_get(c).new}
# must come after --cpu in commandline
opt.on('--16','set cpu in 16bit mode'){$opts[:cpu].size=16}
opt.on('--le','set cpu in little-endian mode'){$opts[:cpu].endianness=:little}
opt.on('--be','set cpu in big-endian mode'){$opts[:cpu].endianness=:big}