Blame SOURCES/0008-Improve-help-for-dnf-module-command-RhBug1758447.patch

8c93e6
From 27d2957e5051cc2edbea3a0d28a630e7eabfd673 Mon Sep 17 00:00:00 2001
8c93e6
From: Marek Blaha <mblaha@redhat.com>
8c93e6
Date: Fri, 6 Dec 2019 09:19:11 +0100
8c93e6
Subject: [PATCH] Improve help for 'dnf module' command (RhBug:1758447)
8c93e6
8c93e6
Added short summary for each subcommand of the 'dnf module' command.
8c93e6
8c93e6
https://bugzilla.redhat.com/show_bug.cgi?id=1758447
8c93e6
---
8c93e6
 dnf/cli/commands/module.py | 22 ++++++++++++++++++----
8c93e6
 1 file changed, 18 insertions(+), 4 deletions(-)
8c93e6
8c93e6
diff --git a/dnf/cli/commands/module.py b/dnf/cli/commands/module.py
8c93e6
index 07883af6a3..5a6c0069fb 100644
8c93e6
--- a/dnf/cli/commands/module.py
8c93e6
+++ b/dnf/cli/commands/module.py
8c93e6
@@ -74,6 +74,7 @@ def _get_module_artifact_names(self, use_modules, skip_modules):
8c93e6
     class ListSubCommand(SubCommand):
8c93e6
 
8c93e6
         aliases = ('list',)
8c93e6
+        summary = _('list all module streams, profiles and states')
8c93e6
 
8c93e6
         def configure(self):
8c93e6
             demands = self.cli.demands
8c93e6
@@ -107,6 +108,7 @@ def run_on_module(self):
8c93e6
     class InfoSubCommand(SubCommand):
8c93e6
 
8c93e6
         aliases = ('info',)
8c93e6
+        summary = _('print detailed information about a module')
8c93e6
 
8c93e6
         def configure(self):
8c93e6
             demands = self.cli.demands
8c93e6
@@ -128,6 +130,7 @@ def run_on_module(self):
8c93e6
     class EnableSubCommand(SubCommand):
8c93e6
 
8c93e6
         aliases = ('enable',)
8c93e6
+        summary = _('enable a module stream')
8c93e6
 
8c93e6
         def configure(self):
8c93e6
             demands = self.cli.demands
8c93e6
@@ -151,6 +154,7 @@ def run_on_module(self):
8c93e6
     class DisableSubCommand(SubCommand):
8c93e6
 
8c93e6
         aliases = ('disable',)
8c93e6
+        summary = _('disable a module with all its streams')
8c93e6
 
8c93e6
         def configure(self):
8c93e6
             demands = self.cli.demands
8c93e6
@@ -174,6 +178,7 @@ def run_on_module(self):
8c93e6
     class ResetSubCommand(SubCommand):
8c93e6
 
8c93e6
         aliases = ('reset',)
8c93e6
+        summary = _('reset a module')
8c93e6
 
8c93e6
         def configure(self):
8c93e6
             demands = self.cli.demands
8c93e6
@@ -194,6 +199,7 @@ def run_on_module(self):
8c93e6
     class InstallSubCommand(SubCommand):
8c93e6
 
8c93e6
         aliases = ('install',)
8c93e6
+        summary = _('install a module profile including its packages')
8c93e6
 
8c93e6
         def configure(self):
8c93e6
             demands = self.cli.demands
8c93e6
@@ -214,6 +220,7 @@ def run_on_module(self):
8c93e6
     class UpdateSubCommand(SubCommand):
8c93e6
 
8c93e6
         aliases = ('update',)
8c93e6
+        summary = _('update packages associated with an active stream')
8c93e6
 
8c93e6
         def configure(self):
8c93e6
             demands = self.cli.demands
8c93e6
@@ -230,6 +237,7 @@ def run_on_module(self):
8c93e6
     class RemoveSubCommand(SubCommand):
8c93e6
 
8c93e6
         aliases = ('remove', 'erase',)
8c93e6
+        summary = _('remove installed module profiles and their packages')
8c93e6
 
8c93e6
         def configure(self):
8c93e6
             demands = self.cli.demands
8c93e6
@@ -266,6 +274,7 @@ def run_on_module(self):
8c93e6
     class ProvidesSubCommand(SubCommand):
8c93e6
 
8c93e6
         aliases = ("provides", )
8c93e6
+        summary = _('list modular packages')
8c93e6
 
8c93e6
         def configure(self):
8c93e6
             demands = self.cli.demands
8c93e6
@@ -280,6 +289,7 @@ def run_on_module(self):
8c93e6
     class RepoquerySubCommand(SubCommand):
8c93e6
 
8c93e6
         aliases = ("repoquery", )
8c93e6
+        summary = _('list packages belonging to a module')
8c93e6
 
8c93e6
         def configure(self):
8c93e6
             demands = self.cli.demands
8c93e6
@@ -342,10 +352,14 @@ def set_argparser(self, parser):
8c93e6
         narrows.add_argument('--all', dest='all',
8c93e6
                              action='store_true',
8c93e6
                              help=_("remove all modular packages"))
8c93e6
-
8c93e6
-        subcommand_help = [subcmd.aliases[0] for subcmd in self.SUBCMDS]
8c93e6
-        parser.add_argument('subcmd', nargs=1, choices=subcommand_help,
8c93e6
-                            help=_("Modular command"))
8c93e6
+        subcommand_choices = []
8c93e6
+        subcommand_help = []
8c93e6
+        for subcmd in sorted(self.SUBCMDS, key=lambda x: x.aliases[0]):
8c93e6
+            subcommand_choices.append(subcmd.aliases[0])
8c93e6
+            subcommand_help.append('{}: {}'.format(subcmd.aliases[0], subcmd.summary or ''))
8c93e6
+        parser.add_argument('subcmd', nargs=1, choices=subcommand_choices,
8c93e6
+                            metavar='<modular command>',
8c93e6
+                            help='\n'.join(subcommand_help))
8c93e6
         parser.add_argument('module_spec', metavar='module-spec', nargs='*',
8c93e6
                             help=_("Module specification"))
8c93e6