delete
Implements the database delete subcommand for the Merlin CLI.
This module defines the DatabaseDeleteCommand class, which enables users to
remove entities from the Merlin database through the CLI. It supports targeted
deletion by identifier, bulk deletion of entities with optional filters, and
complete database clearance.
Entity types and their supported operations are dynamically registered via the
ENTITY_REGISTRY, and entity-specific flags (e.g., study-related options) are
automatically integrated into the CLI. This design ensures easy extensibility
as new entities or deletion options are introduced.
Main Capabilities:
- database delete <entity> <ids...>: Delete specific entities by their IDs.
- database delete all-<entity>: Delete all instances of an entity type with optional filters.
- database delete everything: Delete the entire database, with optional force flag.
DatabaseDeleteCommand
Bases: CommandEntryPoint
Handles the database delete subcommand, which deletes entities from the
Merlin database based on type, identifiers, and filters.
Methods:
| Name | Description |
|---|---|
add_parser |
Register the |
process_command |
Dispatch the appropriate database deletion logic based on CLI args. |
_delete_entities |
Deletes specific entities. |
_delete_all_entities |
Deletes all entities of a type, applying filters if present. |
Source code in merlin/cli/commands/database/delete.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
add_parser(database_commands)
Add the database delete subcommand parser to the CLI argument parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database_commands
|
ArgumentParser
|
The subparsers object to which the |
required |
Source code in merlin/cli/commands/database/delete.py
process_command(args)
Process the database delete command using the provided CLI arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Namespace
|
Parsed CLI arguments from the user. |
required |