Browse Source

Merge pull request #3155 from ThomasWaldmann/maincommand-help-1.1

maincommand help 1.1
TW 7 years ago
parent
commit
17ce2f728a
2 changed files with 11 additions and 0 deletions
  1. 8 0
      docs/usage/general.rst
  2. 3 0
      src/borg/archiver.py

+ 8 - 0
docs/usage/general.rst

@@ -30,3 +30,11 @@ Common options
 All Borg commands share these options:
 All Borg commands share these options:
 
 
 .. include:: common-options.rst.inc
 .. include:: common-options.rst.inc
+
+Examples
+~~~~~~~~
+::
+
+    # Create an archive and log: borg version, files list, return code
+    $ borg create --show-version --list --show-rc /path/to/repo::my-files files
+

+ 3 - 0
src/borg/archiver.py

@@ -2156,6 +2156,8 @@ class Archiver:
         parser.print_help()
         parser.print_help()
         return EXIT_SUCCESS
         return EXIT_SUCCESS
 
 
+    do_maincommand_help = do_subcommand_help
+
     def preprocess_args(self, args):
     def preprocess_args(self, args):
         deprecations = [
         deprecations = [
             # ('--old', '--new' or None, 'Warning: "--old" has been deprecated. Use "--new" instead.'),
             # ('--old', '--new' or None, 'Warning: "--old" has been deprecated. Use "--new" instead.'),
@@ -2423,6 +2425,7 @@ class Archiver:
 
 
         parser = argparse.ArgumentParser(prog=self.prog, description='Borg - Deduplicated Backups',
         parser = argparse.ArgumentParser(prog=self.prog, description='Borg - Deduplicated Backups',
                                          add_help=False)
                                          add_help=False)
+        parser.set_defaults(func=functools.partial(self.do_maincommand_help, parser))
         parser.common_options = self.CommonOptions(define_common_options,
         parser.common_options = self.CommonOptions(define_common_options,
                                                    suffix_precedence=('_maincommand', '_midcommand', '_subcommand'))
                                                    suffix_precedence=('_maincommand', '_midcommand', '_subcommand'))
         parser.add_argument('-V', '--version', action='version', version='%(prog)s ' + __version__,
         parser.add_argument('-V', '--version', action='version', version='%(prog)s ' + __version__,