From d18320aa66d7ad64f2a957d164a8d6ff5de2c78c Mon Sep 17 00:00:00 2001 From: Conrad Johnston Date: Mon, 6 Mar 2023 19:28:58 +0000 Subject: [PATCH] Generate content for `verdi code show` automatically Some CLI commands like `verdi code show` rely on printing various node attributes 'by hand' and so may miss certain attributes and must be maintained 'by hand' on an ongoing basis. This commit uses `get_cli_options` to populate the output table for the `show` subcommand automatically, so as to ensure completeness of output and to simplify future maintenance. --- aiida/cmdline/commands/cmd_code.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/aiida/cmdline/commands/cmd_code.py b/aiida/cmdline/commands/cmd_code.py index fff74b48cb..d32165720c 100644 --- a/aiida/cmdline/commands/cmd_code.py +++ b/aiida/cmdline/commands/cmd_code.py @@ -224,12 +224,12 @@ def show(code): table = [] table.append(['PK', code.pk]) table.append(['UUID', code.uuid]) - table.append(['Label', code.label]) - table.append(['Description', code.description]) - table.append(['Default plugin', code.default_calc_job_plugin]) - table.append(['Prepend text', code.prepend_text]) - table.append(['Append text', code.append_text]) - + table.append(['Type', code.entry_point.name]) + for key in code.get_cli_options().keys(): + try: + table.append([key.capitalize().replace('_', ' '), getattr(code, key)]) + except AttributeError: + continue if is_verbose(): table.append(['Calculations', len(code.base.links.get_outgoing().all())])