Skip to content

Commit

Permalink
Command line arguments parser rewrite and help clarification
Browse files Browse the repository at this point in the history
Help for dnf commands is now divided into two parts - "General DNF options"
and "Command specific options". This commit also prevents mixing
options from these two distinct groups together which was previous behavior
for argument from mutually exclusive groups (e.g. --best/--nobest).
Also the command specific options are printed later - under the general ones,
so the user sees them on the screen without need to scroll up.

Due to the problems with groups behaviour in python argparse, we need to avoid
using "inheritance" in argument definition.
Basically the problem is, that when you use parents=[] in ArgumentParser
constructor, mutually exclusive groups are forgotten. See
https://bugs.python.org/issue16807
https://bugs.python.org/issue25882

https://bugzilla.redhat.com/show_bug.cgi?id=1659328
  • Loading branch information
m-blaha authored and lukash committed Jun 20, 2019
1 parent ace9961 commit de9643a
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 90 deletions.
2 changes: 1 addition & 1 deletion dnf/cli/commands/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class GroupCommand(commands.Command):

def _canonical(self):
# were we called with direct command?
direct = self.direct_commands.get(self.opts.command[0])
direct = self.direct_commands.get(self.opts.command)
if direct:
# canonize subcmd and args
if self.opts.subcmd is not None:
Expand Down
2 changes: 1 addition & 1 deletion dnf/cli/commands/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,5 +307,5 @@ def check_required_argument(self):
if self.opts.subcmd[0] not in not_required_argument:
if not self.opts.module_spec:
raise CliError(
"dnf {} {}: too few arguments".format(self.opts.command[0],
"dnf {} {}: too few arguments".format(self.opts.command,
self.opts.subcmd[0]))

0 comments on commit de9643a

Please sign in to comment.