chiark / gitweb /
stgit.el: Forbid stgit-{delete,edit,mark,rename} on index and work tree
[stgit] / stg-build
index 8c39a6ffdafc7a6437415a9dee8149dae99fb754..2af652342fb450d949b1502f6d16d89f9394f6c5 100755 (executable)
--- a/stg-build
+++ b/stg-build
@@ -2,7 +2,7 @@
 # -*- python -*-
 import optparse, sys
 import stgit.main
-from stgit import argparse
+from stgit import argparse, commands, completion
 
 def main():
     op = optparse.OptionParser()
@@ -10,6 +10,12 @@ def main():
                   help = 'Print asciidoc documentation for a command')
     op.add_option('--commands', action = 'store_true',
                   help = 'Print list of all stg subcommands')
+    op.add_option('--cmd-list', action = 'store_true',
+                  help = 'Print asciidoc command list')
+    op.add_option('--py-cmd-list', action = 'store_true',
+                  help = 'Write Python command list')
+    op.add_option('--bash-completion', action = 'store_true',
+                  help = 'Write bash completion code')
     options, args = op.parse_args()
     if args:
         op.error('Wrong number of arguments')
@@ -17,8 +23,17 @@ def main():
         argparse.write_asciidoc(stgit.main.commands[options.asciidoc],
                                 sys.stdout)
     elif options.commands:
-        for cmd in sorted(stgit.main.commands.iterkeys()):
+        for cmd in sorted(commands.get_commands(
+                allow_cached = False).iterkeys()):
             print cmd
+    elif options.cmd_list:
+        commands.asciidoc_command_list(
+            commands.get_commands(allow_cached = False), sys.stdout)
+    elif options.py_cmd_list:
+        commands.py_commands(commands.get_commands(allow_cached = False),
+                             sys.stdout)
+    elif options.bash_completion:
+        completion.write_completion(sys.stdout)
     else:
         op.error('No command')