diff --git a/aiida/cmdline/groups/dynamic.py b/aiida/cmdline/groups/dynamic.py index 2cadef85e1..caead9d3ae 100644 --- a/aiida/cmdline/groups/dynamic.py +++ b/aiida/cmdline/groups/dynamic.py @@ -41,12 +41,20 @@ def cmd_create(): """ - def __init__(self, command, entry_point_group: str, entry_point_name_filter=r'.*', **kwargs): + def __init__( + self, + command, + entry_point_group: str, + entry_point_name_filter: str = r'.*', + shared_options: list[click.Option] | None = None, + **kwargs + ): super().__init__(**kwargs) self.command = command self.entry_point_group = entry_point_group self.entry_point_name_filter = entry_point_name_filter self.factory = ENTRY_POINT_GROUP_FACTORY_MAPPING[entry_point_group] + self.shared_options = shared_options def list_commands(self, ctx) -> list[str]: """Return the sorted list of subcommands for this group. @@ -97,6 +105,12 @@ def apply_options(func): for option in options_list: func = option(func) + shared_options = self.shared_options or [] + shared_options.reverse() + + for option in shared_options: + func = option(func) + return func return apply_options