summaryrefslogtreecommitdiff
path: root/README
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2011-05-26 15:58:09 +0100
committerLars Wirzenius <liw@liw.fi>2011-05-26 15:58:09 +0100
commitc24e692c85250294ff3ea7ed956f8f4c70969812 (patch)
tree75757e65eddc293f094a5d9191d1997265727f03 /README
parentd7206cd48ef5428e380618b202d854d5686c7c2e (diff)
downloadcliapp-c24e692c85250294ff3ea7ed956f8f4c70969812.tar.gz
Document how subcommands will work.
Diffstat (limited to 'README')
-rw-r--r--README27
1 files changed, 27 insertions, 0 deletions
diff --git a/README b/README
index 240ed98..4f47434 100644
--- a/README
+++ b/README
@@ -67,6 +67,33 @@ It can also run the rest of the code under the Python profiler,
if the appropriate environment variable is set.
+Subcommands
+-----------
+
+Sometimes a command line tool needs to support subcommands.
+For example, version control tools often do this:
+`git commit`, `git clone`, etc. To do this with cliapp,
+you need to add methods with names like `cmd_commit` and
+`cmd_clone`:
+
+ class VersionControlTool(cliapp.Application):
+
+ def cmd_commit(self, args):
+ pass
+ def cmd_clone(self, args):
+ pass
+
+If any such methods exist, cliapp automatically supports
+subcommands. The name of the method, without the `cmd_` prefix,
+forms the name of the subcommand. Any underscores in the method
+name get converted to dashes in the command line. Case is
+preserved.
+
+All options are global, not specific to the subcommand.
+All non-option arguments are passed to the method in its only
+argument.
+
+
Manual pages
------------