]> arthur.barton.de Git - bup.git/commitdiff
ftp: print pwd as part of the prompt
authorJohannes Berg <johannes@sipsolutions.net>
Tue, 28 Jul 2020 20:33:43 +0000 (22:33 +0200)
committerRob Browning <rlb@defaultvalue.org>
Sun, 18 Apr 2021 18:23:19 +0000 (13:23 -0500)
Print the current directory as part of the prompt.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/cmd/ftp.py

index 0dba70ef39e8ed414686c180edfb6ece36417032..4982384c3c65f8178fd3bf038ec835e712faf323 100755 (executable)
@@ -35,28 +35,6 @@ def write_to_file(inf, outf):
         outf.write(blob)
 
 
-def inputiter(f):
-    if os.isatty(f.fileno()):
-        while 1:
-            if hasattr(_helpers, 'readline'):
-                try:
-                    yield _helpers.readline(b'bup> ')
-                except EOFError:
-                    print()  # Clear the line for the terminal's next prompt
-                    break
-            else:
-                out.write(b'bup> ')
-                out.flush()
-                read_line = f.readline()
-                if not read_line:
-                    print('')
-                    break
-                yield read_line
-    else:
-        for line in f:
-            yield line
-
-
 def _completer_get_subs(repo, line):
     (qtype, lastword) = shquote.unfinished_word(line)
     dir, name = os.path.split(lastword)
@@ -134,6 +112,29 @@ def main(argv):
     pwd = vfs.resolve(repo, b'/')
     rv = 0
 
+    def inputiter(f):
+        if os.isatty(f.fileno()):
+            while 1:
+                prompt = b'bup %s> ' % (b'/'.join(name for name, item in pwd) or b'/', )
+                if hasattr(_helpers, 'readline'):
+                    try:
+                        yield _helpers.readline(prompt)
+                    except EOFError:
+                        print()  # Clear the line for the terminal's next prompt
+                        break
+                else:
+                    out.write(prompt)
+                    out.flush()
+                    read_line = f.readline()
+                    if not read_line:
+                        print('')
+                        break
+                    yield read_line
+        else:
+            for line in f:
+                yield line
+
+
     if extra:
         lines = (argv_bytes(arg) for arg in extra)
     else: