Browse Source

default progress display to true if on a tty

this makes --progress a toggle: if there's a terminal, it turns it
off, if there isn't, it forces it on.
Antoine Beaupré 9 năm trước cách đây
mục cha
commit
92ac120fb0
1 tập tin đã thay đổi với 4 bổ sung4 xóa
  1. 4 4
      borg/archiver.py

+ 4 - 4
borg/archiver.py

@@ -677,11 +677,11 @@ Type "Yes I am sure" if you understand this and want to continue.\n""")
         subparser.add_argument('-s', '--stats', dest='stats',
         subparser.add_argument('-s', '--stats', dest='stats',
                                action='store_true', default=False,
                                action='store_true', default=False,
                                help='print statistics for the created archive')
                                help='print statistics for the created archive')
-        subparser.add_argument('-p', '--progress', dest='progress',
-                               action='store_true', default=False,
-                               help="""print progress while creating the archive, showing Original,
+        subparser.add_argument('-p', '--progress', dest='progress', const=not sys.stdin.isatty(),
+                               action='store_const', default=sys.stdin.isatty(),
+                               help="""toggle progress display while creating the archive, showing Original,
                                Compressed and Deduplicated sizes, followed by the Number of files seen
                                Compressed and Deduplicated sizes, followed by the Number of files seen
-                               and the path being processd""")
+                               and the path being processd, default: %(default)s""")
         subparser.add_argument('-e', '--exclude', dest='excludes',
         subparser.add_argument('-e', '--exclude', dest='excludes',
                                type=ExcludePattern, action='append',
                                type=ExcludePattern, action='append',
                                metavar="PATTERN", help='exclude paths matching PATTERN')
                                metavar="PATTERN", help='exclude paths matching PATTERN')