From f81936cee05b003e2327c681af8c9a780c8d8a50 Mon Sep 17 00:00:00 2001 From: Kim Spasaro Date: Mon, 8 Aug 2016 16:01:57 -0500 Subject: [PATCH] adding module list command --- peru/main.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/peru/main.py b/peru/main.py index 0d559e5..56f3c25 100644 --- a/peru/main.py +++ b/peru/main.py @@ -229,6 +229,31 @@ def do_override(params): module, params.runtime.get_override(module))) +@peru_command('module', '''\ +Usage: + peru module [-z] + +Options: + -z print one module per line for machine-readable formatting + +''') +def do_list(params): + modules = params.scope.modules.values() + output = '' + delim = ' | ' if params.args['-z'] else "\n " + + for module in modules: + output += module.name + for field, val in module.plugin_fields.items(): + output += '{}{}: {}'.format(delim, field, val) + if(params.runtime.get_override(module.name)): + output += '{}{}: {}'.format(delim, 'override', params.runtime.get_override(module.name)) + output += '\n' + + if (output): + params.runtime.display.print(output[:-1]) + + def get_version(): version_file = os.path.join(compat.MODULE_ROOT, 'VERSION') with open(version_file) as f: