aiida.cmdline.groups package#

Module with custom implementations of click.Group.


Subclass of click.Group that loads subcommands dynamically from entry points.

class aiida.cmdline.groups.dynamic.DynamicEntryPointCommandGroup(command, entry_point_group: str, entry_point_name_filter='.*', **kwargs)[source]#

Bases: aiida.cmdline.groups.verdi.VerdiCommandGroup

Subclass of click.Group that loads subcommands dynamically from entry points.

A command group using this class will automatically generate the sub commands from the entry points registered in the given entry_point_group. The entry points can be additionally filtered using a regex defined for the entry_point_name_filter keyword. The actual command for each entry point is defined by command, which should take as a first argument the class that corresponds to the entry point. In addition, it should accept kwargs which will be the values for the options passed when the command is invoked. The help string of the command will be provided by the docstring of the class registered at the respective entry point. Example usage:

def create_instance(cls, **kwargs):
    instance = cls(**kwargs)
    echo.echo_success(f'Created {cls.__name__}<{}>')'create', cls=DynamicEntryPointCommandGroup, command=create_instance,)
def cmd_create():
__init__(command, entry_point_group: str, entry_point_name_filter='.*', **kwargs)[source]#
__module__ = 'aiida.cmdline.groups.dynamic'#

Create a subcommand for the given entry_point.

static create_option(name, spec)[source]#

Create a click option from a name and a specification.


Create the option decorators for the command function for the given entry point.


entry_point – The entry point.

get_command(ctx, cmd_name)[source]#

Return the command with the given name.

  • ctx – The click.Context.

  • cmd_name – The name of the command.


The click.Command.

list_commands(ctx) list[str][source]#

Return the sorted list of subcommands for this group.


ctx – The click.Context.


Return the list of options that should be applied to the command for the given entry point.


entry_point – The entry point.

Subclass of click.Group for the verdi CLI.

class aiida.cmdline.groups.verdi.VerdiCommandGroup(name: Optional[str] = None, commands: Optional[Union[Dict[str, click.core.Command], Sequence[click.core.Command]]] = None, **attrs: Any)[source]#

Bases: click.core.Group

Subclass of click.Group for the verdi CLI.

The class automatically adds the verbosity option to all commands in the interface. It also adds some functionality to provide suggestions of commands in case the user provided command name does not exist.

__module__ = 'aiida.cmdline.groups.verdi'#
static add_verbosity_option(cmd)[source]#

Apply the verbosity option to the command, which is common to all verdi commands.


alias of aiida.cmdline.groups.verdi.VerdiContext

fail_with_suggestions(ctx, cmd_name)[source]#

Fail the command while trying to suggest commands to resemble the requested cmd_name.

get_command(ctx, cmd_name)[source]#

Return the command that corresponds to the requested cmd_name.

This method is overridden from the base class in order to two functionalities:

  • If the command is found, automatically add the verbosity option.

  • If the command is not found, attempt to provide a list of suggestions with existing commands that resemble the requested command name.

Note that if the command is not found and resilient_parsing is set to True on the context, then the latter feature is disabled because most likely we are operating in tab-completion mode.

group(*args, **kwargs)[source]#

Ensure that sub command groups use the same class but do not override an explicitly set value.

class aiida.cmdline.groups.verdi.VerdiContext(*args, **kwargs)[source]#

Bases: click.core.Context

Custom context implementation that defines the obj user object and adds the Config instance.

__init__(*args, **kwargs)[source]#
__module__ = 'aiida.cmdline.groups.verdi'#