]> arthur.barton.de Git - bup.git/blobdiff - cmd/ftp-cmd.py
Allow the specification of a repo_dir to some VFS and git operations
[bup.git] / cmd / ftp-cmd.py
index 422e168181749cbc247890bc7834c6a085a3b45b..baa1e08d826cb1064f7c15762398a62247d37ddb 100755 (executable)
@@ -1,57 +1,22 @@
 #!/usr/bin/env python
 import sys, os, stat, fnmatch
-from bup import options, git, shquote, vfs
+from bup import options, git, shquote, vfs, ls
 from bup.helpers import *
 
 handle_ctrl_c()
 
 
-def node_name(text, n):
-    if stat.S_ISDIR(n.mode):
-        return '%s/' % text
-    elif stat.S_ISLNK(n.mode):
-        return '%s@' % text
-    else:
-        return '%s' % text
-
-
 class OptionError(Exception):
     pass
 
 
-ls_optspec = """
-ls [-a] [path...]
---
-a,all   include hidden files in the listing
-"""
-ls_opt = options.Options(ls_optspec, onabort=OptionError)
-
+# Check out lib/bup/ls.py for the opt spec
 def do_ls(cmd_args):
     try:
-        (opt, flags, extra) = ls_opt.parse(cmd_args)
+        ls.do_ls(cmd_args, pwd, onabort=OptionError)
     except OptionError, e:
         return
 
-    L = []
-
-    for path in (extra or ['.']):
-        n = pwd.try_resolve(path)
-
-        if stat.S_ISDIR(n.mode):
-            for sub in n:
-                name = sub.name
-                if opt.all or not len(name)>1 or not name.startswith('.'):
-                    if istty1:
-                        L.append(node_name(name, sub))
-                    else:
-                        print node_name(name, sub)
-        else:
-            if istty1:
-                L.append(node_name(path, n))
-            else:
-                print node_name(path, n)
-        sys.stdout.write(columnate(L, ''))
-
 
 def write_to_file(inf, outf):
     for blob in chunkyreader(inf):
@@ -179,7 +144,10 @@ else:
     if readline:
         readline.set_completer_delims(' \t\n\r/')
         readline.set_completer(completer)
-        readline.parse_and_bind("tab: complete")
+        if sys.platform.startswith('darwin'):
+            # MacOS uses a slighly incompatible clone of libreadline
+            readline.parse_and_bind('bind ^I rl_complete')
+        readline.parse_and_bind('tab: complete')
         init_readline_vars()
     lines = inputiter()