[Yum-devel] [PATCH] Don't spam usage info. for missing arguments, as we don't for bad commands.

tim.lauridsen at gmail.com tim.lauridsen at gmail.com
Fri Apr 15 16:05:02 UTC 2011


On Thu, Apr 14, 2011 at 11:46 PM, James Antill <james at and.org> wrote:

> ---
>  yumcommands.py |   17 +++++++++++++----
>  1 files changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/yumcommands.py b/yumcommands.py
> index fd69f05..8e148a9 100644
> --- a/yumcommands.py
> +++ b/yumcommands.py
> @@ -33,6 +33,15 @@ from yum.i18n import utf8_width, utf8_width_fill,
> to_unicode
>
>  import yum.config
>
> +def _err_mini_usage(base, basecmd):
> +    if basecmd not in base.yum_cli_commands:
> +        base.usage()
> +        return
> +    cmd = base.yum_cli_commands[basecmd]
> +    txt = base.yum_cli_commands["help"]._makeOutput(cmd)
> +    base.logger.critical(_(' Mini usage:\n'))
> +    base.logger.critical(txt)
> +
>  def checkRootUID(base):
>     """
>     Verify that the program is being run by the root user.
> @@ -68,19 +77,19 @@ def checkPackageArg(base, basecmd, extcmds):
>     if len(extcmds) == 0:
>         base.logger.critical(
>                 _('Error: Need to pass a list of pkgs to %s') % basecmd)
> -        base.usage()
> +        _err_mini_usage(base, basecmd)
>         raise cli.CliError
>
>  def checkItemArg(base, basecmd, extcmds):
>     if len(extcmds) == 0:
>         base.logger.critical(_('Error: Need an item to match'))
> -        base.usage()
> +        _err_mini_usage(base, basecmd)
>         raise cli.CliError
>
>  def checkGroupArg(base, basecmd, extcmds):
>     if len(extcmds) == 0:
>         base.logger.critical(_('Error: Need a group or list of groups'))
> -        base.usage()
> +        _err_mini_usage(base, basecmd)
>         raise cli.CliError
>
>  def checkCleanArg(base, basecmd, extcmds):
> @@ -94,7 +103,7 @@ def checkCleanArg(base, basecmd, extcmds):
>     for cmd in extcmds:
>         if cmd not in VALID_ARGS:
>             base.logger.critical(_('Error: invalid clean argument: %r') %
> cmd)
> -            base.usage()
> +            _err_mini_usage(base, basecmd)
>             raise cli.CliError
>
>  def checkShellArg(base, basecmd, extcmds):
> --
> 1.7.3.4
>
> _______________________________________________
> Yum-devel mailing list
> Yum-devel at lists.baseurl.org
> http://lists.baseurl.org/mailman/listinfo/yum-devel


ACK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.baseurl.org/pipermail/yum-devel/attachments/20110415/8e821972/attachment.html>


More information about the Yum-devel mailing list