Blob Blame History Raw
From 27d2957e5051cc2edbea3a0d28a630e7eabfd673 Mon Sep 17 00:00:00 2001
From: Marek Blaha <mblaha@redhat.com>
Date: Fri, 6 Dec 2019 09:19:11 +0100
Subject: [PATCH] Improve help for 'dnf module' command (RhBug:1758447)

Added short summary for each subcommand of the 'dnf module' command.

https://bugzilla.redhat.com/show_bug.cgi?id=1758447
---
 dnf/cli/commands/module.py | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/dnf/cli/commands/module.py b/dnf/cli/commands/module.py
index 07883af6a3..5a6c0069fb 100644
--- a/dnf/cli/commands/module.py
+++ b/dnf/cli/commands/module.py
@@ -74,6 +74,7 @@ def _get_module_artifact_names(self, use_modules, skip_modules):
     class ListSubCommand(SubCommand):
 
         aliases = ('list',)
+        summary = _('list all module streams, profiles and states')
 
         def configure(self):
             demands = self.cli.demands
@@ -107,6 +108,7 @@ def run_on_module(self):
     class InfoSubCommand(SubCommand):
 
         aliases = ('info',)
+        summary = _('print detailed information about a module')
 
         def configure(self):
             demands = self.cli.demands
@@ -128,6 +130,7 @@ def run_on_module(self):
     class EnableSubCommand(SubCommand):
 
         aliases = ('enable',)
+        summary = _('enable a module stream')
 
         def configure(self):
             demands = self.cli.demands
@@ -151,6 +154,7 @@ def run_on_module(self):
     class DisableSubCommand(SubCommand):
 
         aliases = ('disable',)
+        summary = _('disable a module with all its streams')
 
         def configure(self):
             demands = self.cli.demands
@@ -174,6 +178,7 @@ def run_on_module(self):
     class ResetSubCommand(SubCommand):
 
         aliases = ('reset',)
+        summary = _('reset a module')
 
         def configure(self):
             demands = self.cli.demands
@@ -194,6 +199,7 @@ def run_on_module(self):
     class InstallSubCommand(SubCommand):
 
         aliases = ('install',)
+        summary = _('install a module profile including its packages')
 
         def configure(self):
             demands = self.cli.demands
@@ -214,6 +220,7 @@ def run_on_module(self):
     class UpdateSubCommand(SubCommand):
 
         aliases = ('update',)
+        summary = _('update packages associated with an active stream')
 
         def configure(self):
             demands = self.cli.demands
@@ -230,6 +237,7 @@ def run_on_module(self):
     class RemoveSubCommand(SubCommand):
 
         aliases = ('remove', 'erase',)
+        summary = _('remove installed module profiles and their packages')
 
         def configure(self):
             demands = self.cli.demands
@@ -266,6 +274,7 @@ def run_on_module(self):
     class ProvidesSubCommand(SubCommand):
 
         aliases = ("provides", )
+        summary = _('list modular packages')
 
         def configure(self):
             demands = self.cli.demands
@@ -280,6 +289,7 @@ def run_on_module(self):
     class RepoquerySubCommand(SubCommand):
 
         aliases = ("repoquery", )
+        summary = _('list packages belonging to a module')
 
         def configure(self):
             demands = self.cli.demands
@@ -342,10 +352,14 @@ def set_argparser(self, parser):
         narrows.add_argument('--all', dest='all',
                              action='store_true',
                              help=_("remove all modular packages"))
-
-        subcommand_help = [subcmd.aliases[0] for subcmd in self.SUBCMDS]
-        parser.add_argument('subcmd', nargs=1, choices=subcommand_help,
-                            help=_("Modular command"))
+        subcommand_choices = []
+        subcommand_help = []
+        for subcmd in sorted(self.SUBCMDS, key=lambda x: x.aliases[0]):
+            subcommand_choices.append(subcmd.aliases[0])
+            subcommand_help.append('{}: {}'.format(subcmd.aliases[0], subcmd.summary or ''))
+        parser.add_argument('subcmd', nargs=1, choices=subcommand_choices,
+                            metavar='<modular command>',
+                            help='\n'.join(subcommand_help))
         parser.add_argument('module_spec', metavar='module-spec', nargs='*',
                             help=_("Module specification"))