utils
Utilities for the database subcommand.
get_filters_for_entity(args, entity_type)
Extracts filter arguments from parsed CLI input for a specific entity type.
This is used to dynamically build the keyword arguments for querying or deleting entities via the database manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Namespace
|
Parsed command-line arguments. |
required |
entity_type
|
str
|
The entity type whose filter definitions should be used. |
required |
Returns:
| Type | Description |
|---|---|
Dict
|
A dictionary of filter argument names to their provided values. Returns an empry dictionary if the entity is invalid or has no filters. |
Source code in merlin/cli/commands/database/utils.py
setup_db_entity_subcommands(subcommand_parser, subcommand_name)
Dynamically sets up subcommands for each entity type for a given subcommand.
This function adds both singular (<entity>) and plural (all-<entities>) variants
to support direct targeting and filter-based selection, respectively.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subcommand_parser
|
ArgumentParser
|
The parser to which entity subcommands should be added. |
required |
subcommand_name
|
str
|
The name of the subcommand being configured (e.g., "delete", "get"). |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, ArgumentParser]
|
A mapping from subcommand name to the corresponding ArgumentParser instance. |