Merge lp:~jimbaker/juju-jitsu/subcommand-help into lp:juju-jitsu
| Status: | Merged |
|---|---|
| Merged at revision: | 63 |
| Proposed branch: | lp:~jimbaker/juju-jitsu/subcommand-help |
| Merge into: | lp:juju-jitsu |
| Diff against target: |
463 lines (+179/-86) 13 files modified
bin/jitsu.in (+29/-32) sub-commands/aiki/cli.py (+89/-2) sub-commands/aiki/twistutils.py (+14/-1) sub-commands/capfile (+1/-1) sub-commands/deploy (+2/-3) sub-commands/get-service-info (+1/-1) sub-commands/get-unit-info (+1/-1) sub-commands/gource (+2/-2) sub-commands/open-port (+3/-1) sub-commands/run-as-hook (+2/-1) sub-commands/setup-environment (+1/-1) sub-commands/topodump (+2/-0) sub-commands/watch (+32/-40) |
| To merge this branch: | bzr merge lp:~jimbaker/juju-jitsu/subcommand-help |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Mark Mims | 2012-06-22 | Approve on 2012-07-06 | |
|
Review via email:
|
|||
Description of the Change
Adds support for adding help to the toplevel jitsu command. Because the subcommands are implemented as separate scripts, not importable modules, it tries two things:
1. Build a module to exec the script in, as if it were Python code. This does require that any Python scripts adhere to the convention that they use the convention of being side effect free and use __main__, eg something like this code fragment:
if __name__ == '__main__':
main()
This is the case with current code. If the code can be loaded, it then looks for a specific top-level function, make_parser(
2. If step 1 fails, it uses the comment lines as the source for help:
#!/path/
# command - short description
# then any optional usage info as comments,
# blank lines terminating, up to a
# Copyright notice
This results in the following output:
$ jitsu -h
usage: jitsu [-h] [--version] subcommand ...
External tools for working with Juju
optional arguments:
-h, --help show this help message and exit
--version show program's version number and exit
subcommands:
Subcommands for jitsu
subcommand
help get subcommand help
capfile returns a capistrano formatted version of the juju status
deploy uses local repo like the charm store
get-
get-unit-info returns requested unit info
gource converts juju status yaml output into gource log
open-port opens a port on a service unit or for all units in a
run-as-hook runs a script or command as if it were a hook, on this
setup-
topodump dumps the zookeeper topology
upgrade-charm upgrade-charm
watch waits on Juju environment for specified conditions
wrap-juju execs an interactive shell with juju wrapped
with detailed help currently available only on jitsu watch --help; the remaining commands can be modified as it makes sense.
| Jim Baker (jimbaker) wrote : | # |

I pushed a new version which does the following:
1) Resolves symlinks so commands can specify their help in comments, but be pointed at by multiple symlinked versions
2) Only attempts the help parsing with make_parser if the command is a jitsu builtin, not from the users plugin directory.