@@ -108,14 +108,19 @@ status.add_argument('-d', '--dest-branch', type=str,
status.add_argument('-f', '--force', action=BooleanOptionalAction,
help='Force overwriting an existing branch')
-# Parse options twice: first to get the project and second to handle
-# defaults properly (which depends on project)
-# Use parse_known_args() in case 'cmd' is omitted
+# Parse options several times:
+# - First to get the project.
+# - Second to handle defaults properly (which depends on project). This
+# makes help display the right defaults.
+# - Finally after we have added an implicit command if necessary.
+#
+# Use parse_known_args() for the first two in case 'cmd' is omitted
+argv = [arg for arg in sys.argv[1:] if arg not in ('-h', '--help')]
+args, _ = parser.parse_known_args(argv)
argv = sys.argv[1:]
-args, rest = parser.parse_known_args(argv)
if hasattr(args, 'project'):
settings.Setup(gitutil, parser, args.project, '')
- args, rest = parser.parse_known_args(argv)
+args, rest = parser.parse_known_args(argv)
# If we have a command, it is safe to parse all arguments
if args.cmd: