Closed jovanbulck closed 9 years ago
kotnetcli -h dump:
usage: Script om in- of uit te loggen op KotNet [-h] [-v] [-l] [-d [LEVEL]] [-i] [-o] [-k] [-f] [-g] [-t] [-c COL COL COL COL]
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-l, --license show license info and exit
-d [LEVEL], --debug [LEVEL]
specify the debug verbosity
worker options:
-i, --login Logs you in on KotNet (default)
-o, --logout Logs you out off KotNet
credentials options:
-k, --keyring Makes kotnetcli pick up your credentials from the keyring (default)
-f, --forget Makes kotnetcli forget your credentials
-g, --guest-mode Logs you in as a different user without forgetting your default credentials
communicator options:
-t, --plaintext Logs you in using plaintext output
-c COL COL COL COL, --color COL COL COL COL
Logs you in using colored text output (default); arguments = ok_color, wait_color, err_color, style
Looks good, merged. Thank you!
allows a user to specify custom colors and style for the
Colorama
communicator via optional cli arguments:The implementation also serves as a proof-of-concept on how to customize communicators without sacrificing cohesion and separation of concerns. This is done using constructor arguments passed through the factory, allowing the front-end to get the parameters from the user in any way. Here it's done through cli arguments; analogously it can be done through a GUI, config file, etc.
Note that, to support multiple command line arguments, I had to let go the
add_mutually_exclusive_group()
. While my solution doesn't report an error on adding multiple conflicting options (for now), it only executes one option (as defined by theelif
switches) and furthermore allows grouping in the help messages:Lastly, the debug option is improved in that it requires an argument of
choices=[ 'critical', 'error', 'warning', 'info', 'debug' ]
and defaults to debug if option present but no level specified