]> Frank Brehm's Git Trees - pixelpark/puppet-tools.git/commitdiff
Adding command line parameter '--details' to bin/get-forge-module
authorFrank Brehm <frank.brehm@pixelpark.com>
Tue, 14 Feb 2023 16:29:32 +0000 (17:29 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Tue, 14 Feb 2023 16:29:32 +0000 (17:29 +0100)
lib/dpx_puppettools/app/get_forge_module.py

index 9d6eb0abc7d96dc7231655510d19bb2dcd4a0c79..82dca051102566264c7844599271b405dbdadabe 100644 (file)
@@ -32,7 +32,7 @@ LOG = logging.getLogger(__name__)
 _ = XLATOR.gettext
 ngettext = XLATOR.ngettext
 
-__version__ = '0.6.2'
+__version__ = '0.6.3'
 
 
 # =============================================================================
@@ -58,6 +58,7 @@ class GetForgeModuleApplication(BaseDPXPuppetApplication):
         self.module_name = None
         self.module_info = None
         self.var_dir = None
+        self.details = False
 
         self._force_desc_msg = _(
             "Write the cache file also, if the data was successful read from chache file.")
@@ -112,10 +113,14 @@ class GetForgeModuleApplication(BaseDPXPuppetApplication):
             "Cache files for the forge information are read and written from the sub "
             "directory {sd!r} below it.").format(vd=str(DEFAULT_VAR_DIR), sd='forge')
         forge_group.add_argument(
-            '-D', '--dir', '--var-dir', dest='var_dir', metavar=_('DIRECTORY'),
+            '--dir', '--var-dir', dest='var_dir', metavar=_('DIRECTORY'),
             action=DirectoryOptionAction, must_exists=True, help=help_txt,
         )
 
+        help_txt = _("Show more details of the forge module.")
+        forge_group.add_argument(
+            '-D', '--details', dest="details", action="store_true", help=help_txt)
+
         forge_group.add_argument(
             'module_name', metavar=_('PUPPET-MODULE'), nargs=1,
             help=_("The name of the module, which data should be retrieved from Puppet forge."),
@@ -158,6 +163,8 @@ class GetForgeModuleApplication(BaseDPXPuppetApplication):
         else:
             var_dir = self.cfg.var_dir
 
+        self.details = getattr(self.args, 'details', False)
+
         self.module_name = self.args.module_name[0]
 
         LOG.debug(_("Creating a {} object ...").format('ForgeModuleInfo'))
@@ -215,7 +222,7 @@ class GetForgeModuleApplication(BaseDPXPuppetApplication):
             LOG.debug(_("Module-Info:") + '\n' + pp(self.module_info.as_dict()))
             self.empty_line()
 
-        self.module_info.show()
+        self.module_info.show(detail=self.details)
         print(_('Last checked for Puppet forge:') + ' ' + self.module_info.date_checked)
         self.empty_line()