diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/fedpkg.bash | 6 | ||||
-rwxr-xr-x | src/fedpkg.py | 33 |
2 files changed, 33 insertions, 6 deletions
diff --git a/src/fedpkg.bash b/src/fedpkg.bash index 2d0f4d8..ea8fffd 100644 --- a/src/fedpkg.bash +++ b/src/fedpkg.bash @@ -93,7 +93,7 @@ _fedpkg() local after= after_more= case $command in - help|clog|gimmespec|giturl|lint|mockbuild|new|push|unused-patches|update|verrel) + clog|gimmespec|giturl|lint|mockbuild|new|push|unused-patches|update|verrel) ;; build) options="--nowait --background --skip-tag --scratch" @@ -130,6 +130,9 @@ _fedpkg() after="file" after_more=true ;; + help) + after="command" + ;; import) options="--create" options_branch="--branch" @@ -241,6 +244,7 @@ _fedpkg() case $after in file) _filedir_exclude_paths; compgen_extra=${COMPREPLY[@]} ;; srpm) _filedir_exclude_paths "*.src.rpm"; compgen_extra=${COMPREPLY[@]} ;; + command) compgen_extra="${commands}" ;; branch) after_options="$(_fedpkg_branch "$path")" ;; package) after_options="$(_fedpkg_package "$cur")";; esac diff --git a/src/fedpkg.py b/src/fedpkg.py index 9e78a28..adc0ab0 100755 --- a/src/fedpkg.py +++ b/src/fedpkg.py @@ -140,9 +140,26 @@ class TaskWatcher(object): else: return koji.TASK_STATES[info['state']].lower() -# Add a simple function to print usage, for the 'help' command -def usage(args, parser): - parser.print_help() +# Call this cmd_help() instead of just help() as the latter is a +# Python builtin function. +def cmd_help(args, parser, subparsers): + """\ + When 'fedpkg help' is called without an additional parameter, + print the fedpkg help message with a complete list of commands and + exit. + + When 'fedpkg help subcommand' is called with the 'subcommand' + parameter, print the help message for that subcommand and exit. + """ + subcmd = args.subcommand + if subcmd: + if subcmd in subparsers.choices: + command_subparser = subparsers.choices[subcmd] + command_subparser.print_help() + else: + print "Error: There is no such fedpkg subcommand like '%s'" % subcmd + else: + parser.print_help() # Define our stub functions def _is_secondary(module): @@ -889,8 +906,14 @@ def parse_cmdline(generate_manpage = False): # Set up the various actions # Add help to -h and --help - parser_help = subparsers.add_parser('help', help = 'Show usage') - parser_help.set_defaults(command = lambda args: usage(args, parser=parser)) + parser_help = subparsers.add_parser('help', + help = 'Print help on fedpkg or one of its subcommands', + formatter_class=argparse.RawDescriptionHelpFormatter, + description = textwrap.dedent(cmd_help.__doc__)) + parser_help.add_argument('subcommand', nargs='?', + help='the fedpkg subcommand to print help for') + parser_help.set_defaults(command = lambda args: cmd_help(args, parser=parser, + subparsers=subparsers)) # Add a common build parser to be used as a parent parser_build_common = subparsers.add_parser('build_common', |