nicob87 opened a new pull request #576: optparse to argparse migration URL: https://github.com/apache/qpid-dispatch/pull/576 Main reason to migrate from optparse to argparse is python documentation itself. - from: https://docs.python.org/2/library/optparse.html Deprecated since version 2.7: The optparse module is deprecated and will not be developed further; development will continue with the argparse module. - from: https://docs.python.org/2/library/argparse.html The argparse module improves on the standard library optparse module in a number of ways including: Handling positional arguments. Supporting sub-commands. Allowing alternative option prefixes like + and /. Handling zero-or-more and one-or-more style arguments. Producing more informative usage messages. Providing a much simpler interface for custom type and action. Note (from argparse doc): - Keep in mind that what was previously called options, now in the argparse context is called args. Regarding to the migration job done in this pr: - optarse library is removed from the source, all library argument parsing is now done with argparse. - version argument is now handled by argparse, that supports special version argument. - qdstat arguments: fully handled by argparse library. - qdmanage arguments: all optparse arguments are now migrated to argparse. - positional argument parsing (operation) remains "unmodified", in the future it may be changed so argparse also parsing positional arguments. - incompatible arguments (like -r, --all-routers) or (-c --all-entities) are now handled by the special "mutually_exclusive_group". - Help message is also handled by argparse. - Usage message is also handled by argparse. - some unittests created to test specifically the parsing. - some more could be added. - some unittests added to the "main" method in command.py module. - help messages could be customized, right now they are being printed with the default argparse format. qdstat_help: ``` usage: qdstat [-h] [-b URL] [-t SECS] [--ssl-certificate CERT] [--ssl-key KEY] [--ssl-trustfile TRUSTED-CA-DB] [--ssl-password PASSWORD] [--ssl-password-file SSL-PASSWORD-FILE] [--sasl-mechanisms SASL-MECHANISMS] [--sasl-username SASL-USERNAME] [--sasl-password SASL-PASSWORD] [--sasl-password-file SASL-PASSWORD-FILE] [--ssl-disable-peer-name-verify] [--version] [-v] [-g | -c | -l | -n | -e | -a | -m | --autolinks | --linkroutes | --log | --all-entities] [--all-routers | -r ROUTER-ID] [--limit LIMIT] optional arguments: -h, --help show this help message and exit --version show program's version number and exit -v, --verbose Show maximum detail --limit LIMIT Limit number of output rows Connection: Connection Options -b URL, --bus URL URL of the messaging bus to connect to default 0.0.0.0 -t SECS, --timeout SECS Maximum time to wait for connection in seconds default 5 --ssl-certificate CERT Client SSL certificate (PEM Format) --ssl-key KEY Client SSL private key (PEM Format) --ssl-trustfile TRUSTED-CA-DB Trusted Certificate Authority Database file (PEM Format) --ssl-password PASSWORD Certificate password, will be prompted if not specifed. --ssl-password-file SSL-PASSWORD-FILE Certificate password, will be prompted if not specifed. --sasl-mechanisms SASL-MECHANISMS Allowed sasl mechanisms to be supplied during the sasl handshake. --sasl-username SASL-USERNAME User name for SASL plain authentication --sasl-password SASL-PASSWORD Password for SASL plain authentication --sasl-password-file SASL-PASSWORD-FILE Password for SASL plain authentication --ssl-disable-peer-name-verify Disables SSL peer name verification. WARNING - This option is insecure and must not be used in production environments Display: Choose what kind of information you want to be displayed -g, --general Show General Router Stats -c, --connections Show Connections -l, --links Show Router Links -n, --nodes Show Router Nodes -e, --edge Show edge connections -a, --address Show Router Addresses -m, --memory Show Router Memory Stats --autolinks Show Auto Links --linkroutes Show Link Routes --log Show recent log entries --all-entities Show all router entities. Can be combined with --all- routers option Target: Choose destination router to required, default the one you connect to. --all-routers Show entities for all routers in network. Can also be used in combination with other options -r ROUTER-ID, --router ROUTER-ID Router to be queried ``` qdmanage help: ``` usage: qdmanage [-h] [-b URL] [-t SECS] [--ssl-certificate CERT] [--ssl-key KEY] [--ssl-trustfile TRUSTED-CA-DB] [--ssl-password PASSWORD] [--ssl-password-file SSL-PASSWORD-FILE] [--sasl-mechanisms SASL-MECHANISMS] [--sasl-username SASL-USERNAME] [--sasl-password SASL-PASSWORD] [--sasl-password-file SASL-PASSWORD-FILE] [--ssl-disable-peer-name-verify] [--version] [-v] [-r ROUTER-ID] [--type TYPE] [--name NAME] [--identity ID] [--indent INDENT] [--stdin] [--body BODY] [--properties PROPERTIES] optional arguments: -h, --help show this help message and exit --version show program's version number and exit -v, --verbose Show maximum detail -r ROUTER-ID, --router ROUTER-ID Router to be queried --type TYPE Type of entity to operate on. --name NAME Name of entity to operate on. --identity ID Identity of entity to operate on. --indent INDENT Pretty-printing indent. -1 means don't pretty-print (default 2) --stdin Read attributes as JSON map or list of maps from stdin. --body BODY JSON value to use as body of a non-standard operation call. --properties PROPERTIES JSON map to use as properties for a non-standard operation call. Connection: Connection Options -b URL, --bus URL URL of the messaging bus to connect to default 0.0.0.0 -t SECS, --timeout SECS Maximum time to wait for connection in seconds default 5 --ssl-certificate CERT Client SSL certificate (PEM Format) --ssl-key KEY Client SSL private key (PEM Format) --ssl-trustfile TRUSTED-CA-DB Trusted Certificate Authority Database file (PEM Format) --ssl-password PASSWORD Certificate password, will be prompted if not specifed. --ssl-password-file SSL-PASSWORD-FILE Certificate password, will be prompted if not specifed. --sasl-mechanisms SASL-MECHANISMS Allowed sasl mechanisms to be supplied during the sasl handshake. --sasl-username SASL-USERNAME User name for SASL plain authentication --sasl-password SASL-PASSWORD Password for SASL plain authentication --sasl-password-file SASL-PASSWORD-FILE Password for SASL plain authentication --ssl-disable-peer-name-verify Disables SSL peer name verification. WARNING - This option is insecure and must not be used in production environments Operation: Standard operations: QUERY, CREATE, READ, UPDATE, DELETE, GET-TYPES, GET- OPERATIONS, GET-ATTRIBUTES, GET-ANNOTATIONS, GET-MGMT-NODES, GET-SCHEMA, GET-LOG. Use GET-OPERATIONS to find additional operations. ```
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
