]> arthur.barton.de Git - bup.git/commitdiff
bup: include built-in subcommands in help
authorRob Browning <rlb@defaultvalue.org>
Sun, 13 Dec 2020 17:05:52 +0000 (11:05 -0600)
committerRob Browning <rlb@defaultvalue.org>
Sat, 6 Mar 2021 18:29:38 +0000 (12:29 -0600)
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/cmd/__init__.py [new file with mode: 0644]
lib/cmd/bup

diff --git a/lib/bup/cmd/__init__.py b/lib/bup/cmd/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
index e7dd854a9aab7080566094327fd016f0bd82e6b9..cc437f608b6a71bcc3b1d1be474ad3c89dc27a61 100755 (executable)
@@ -31,6 +31,7 @@ import os, sys
 sys.path[:0] = [os.path.dirname(os.path.realpath(__file__)) + '/..']
 
 from importlib import import_module
+from pkgutil import iter_modules
 from subprocess import PIPE
 from threading import Thread
 import errno, getopt, os, re, select, signal, subprocess, sys
@@ -58,6 +59,7 @@ from bup.helpers import (
 from bup.git import close_catpipes
 from bup.io import byte_stream, path_msg
 from bup.options import _tty_width
+import bup.cmd
 
 def maybe_import_early(argv):
     """Scan argv and import any modules specified by --import-py-module."""
@@ -107,13 +109,19 @@ def usage(msg=""):
     log('\n')
     
     log('Other available commands:\n')
-    cmds = []
+    cmds = set()
     for c in sorted(os.listdir(cmdpath)):
         if c.startswith(b'bup-') and c.find(b'.') < 0:
             cname = fsdecode(c[4:])
             if cname not in common:
-                cmds.append(c[4:].decode(errors='backslashreplace'))
-    log(columnate(cmds, '    '))
+                cmds.add(c[4:].decode(errors='backslashreplace'))
+    # built-in commands take precedence
+    for _, name, _ in iter_modules(path=bup.cmd.__path__):
+        name = name.replace('_','-')
+        if name not in common:
+            cmds.add(name)
+
+    log(columnate(sorted(cmds), '    '))
     log('\n')
     
     log("See 'bup help COMMAND' for more information on " +