#2526 sidetag: remove double "usage"
Merged 2 years ago by tkopecek. Opened 2 years ago by tkopecek.
tkopecek/koji issue2489  into  master

file modified
+4 -4
@@ -16,7 +16,7 @@ 

  @export_cli

  def handle_add_sidetag(options, session, args):

      "Create sidetag"

-     usage = _("usage: %(prog)s add-sidetag [options] <basetag>")

+     usage = _("%(prog)s add-sidetag [options] <basetag>")

      usage += _("\n(Specify the --help global option for a list of other help options)")

      parser = ArgumentParser(usage=usage)

      parser.add_argument("basetag", help="name of basetag")
@@ -56,7 +56,7 @@ 

  @export_cli

  def handle_remove_sidetag(options, session, args):

      "Remove sidetag"

-     usage = _("usage: %(prog)s remove-sidetag [options] <sidetag> ...")

+     usage = _("%(prog)s remove-sidetag [options] <sidetag> ...")

      usage += _("\n(Specify the --help global option for a list of other help options)")

      parser = ArgumentParser(usage=usage)

      parser.add_argument("sidetags", help="name of sidetag", nargs="+")
@@ -73,7 +73,7 @@ 

  @export_cli

  def handle_list_sidetags(options, session, args):

      "List sidetags"

-     usage = _("usage: %(prog)s list-sidetags [options]")

+     usage = _("%(prog)s list-sidetags [options]")

      usage += _("\n(Specify the --help global option for a list of other help options)")

      parser = ArgumentParser(usage=usage)

      parser.add_argument("--basetag", action="store", help=_("Filter on basetag"))
@@ -98,7 +98,7 @@ 

  @export_cli

  def handle_edit_sidetag(options, session, args):

      "Edit sidetag"

-     usage = _("usage: %(prog)s edit-sidetag [options]")

+     usage = _("%(prog)s edit-sidetag [options]")

      usage += _("\n(Specify the --help global option for a list of other help options)")

      parser = ArgumentParser(usage=usage)

      parser.add_argument("sidetag", help="name of sidetag")

Metadata Update from @tkopecek:
- Pull-request tagged with: doc, no_qe

2 years ago

@jcupova found the difference between optparse and argparse

in optparse, it is a capitalized "Usage: ..." but in argparse, it is "usage: ..."

a simple hacking like this would change the behavior, but I'm not sure if it is worthy here

def fake_add_usage(self, usage, actions, groups, prefix="Usage: "):
    args = usage, actions, groups, prefix
    self._add_item(self._format_usage, args)


HelpFormatter.add_usage = fake_add_usage

Let's ignore this for now - In "some" future we would move to argparse anyway and maybe in combination with some cli/plugin framework. So, for now it is the only place (as it was in original external plugin)

Commit 6dd313b fixes this pull-request

Pull-Request has been merged by tkopecek

2 years ago
Metadata