Python:
# python allows keyword arguments
parser = argparse.ArgumentParser(prog='PROG', usage='%(prog)s [options]')
Javascript:
// keyword arguments are passed as a single `options` object
parser = argparse.ArgumentParser({ prog: 'PROG', usage: '%(prog)s [options]' })
Python:
parser.add_argument('--foo', type=int)
Javascript:
parser.add_argument('--foo', { type: 'int' })
Python raises TypeError or ValueError for various argument errors. Javascript raises TypeError in both cases.
You should be closing it with .close()
if available (which doesn't exist for stdin/stdout).
Override Action.call
instead of Action.__call__
in inherited classes
%s
is rendered asString(arg)
%r
is rendered asutil.inspect(arg)
%d
,%i
is rendered asarg.toFixed(0)
, no precision digits or padding is supported- no other formats are implemented yet
All error messages are hardcoded.