An application based on Cmds will now try to read StringTree formatted config data from a file $HOME/.<name>rc, and make the data available via the newly added conf_value() method.
WSGI doesn't like sys.exit() being called, so avoid it. Two cases need to be taken into consideration:
1. No exception thrown by self.args.func()
The variable exit_status is zero, we can check that and _not_
call sys.exit()
2. Exception thrown by self.args.func()
In that case, the exception should be raised, to be caught by
WSGI / ASGI whatever to do what they want with it. The code
calling sys.exit() is never reached. Hence, we need to add
--backtrace to the invocation options.
The parsed args container is passed to the run() function and friends for convenient use. Sometimes, though, the base classes or umbrella commands need to make use of it, too, even more so as they may define command line arguments via add_arguments(). However, run() or _run() or whatever is never called on them, neither any other callback, so make args available to them as a member variable.
jwutils.Cmd.add_subcommands() had two issues. First, it failed for more than one command, and with that fixed, it only added the first command of a list of commands passed as an argument. This commit fixes both issues and leaves some logging and cleanup in place, which was used during debugging.
Cmds.cmds was sometimes empty, so fix that and make sure it points to the Cmds instance it was crated by. Actually the name of the Cmds class is a bad pick, should have been App or something, so to add .app, too, as a path for future compatibility.
jwutils.log.set_flags() and .set_level() is not set until after all commands are loaded. This can make debugging complicated. OTOH, command-line parsing is also not done until all commands are loaded, because they define the command line options. This commit adds some poor man's command line parsing for fetching --log-level and --log-flags only, and applying them before the commands are all loaded.
This commit makee Cmds run all sub-commands in an asyncio event loop. The event loop is currently passed to the commands, which seems unnecessary and looks like it's using a feature which is bound to be deprecated in the future.
o basestring is merged into str o print() needs parentesis o Class inheritance syntax changed o Abstract baseclass (ABCMeta) syntax changed o map.iteritems() is replaced by map.items() o Inconsistent use of tabs and spaces are no longer tolerated
run_sub_commands() was the only way to access subcommands up to now, Cmds.run() adds another interface, an object as a place to add customizations affecting all commands, e.g. global command line options.