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).
Only basic read and write modes are implemented. Support for the remaining
modes will not be added: FileType is deprecated, emits a
PendingDeprecationWarning, and is expected to be removed.
Override Action.call instead of Action.__call__ in inherited classes
%sis rendered asString(arg)%ris rendered asutil.inspect(arg)%d,%iis rendered asarg.toFixed(0), no precision digits or padding is supported- no other formats are implemented yet
All error messages are hardcoded.
Python's ArgumentParser can be serialized with pickle. JavaScript has no
equivalent serialization mechanism, so this behavior is not supported.
ArgumentError.message contains the final formatted error message. Unlike
Python, separate argument_name and raw message fields are not exposed.
print_help(file), print_usage(file), and parser error output write messages
to the supplied file object. An object without a .write() method is ignored,
as in Python. Exceptions thrown by a custom .write() implementation are not
suppressed.
Unlike Python file objects, Node.js streams normally report I/O failures through
the error event or a write callback rather than by throwing an OSError from
.write(). Those errors must be handled on the stream itself.