Add `entry_point` command to `interface`. Parameters ---------- interface : click.Command or click.Group The click interface to augment with `entry_point`. entry_point : importlib.metadata.EntryPoint The entry point which loads to a ``click.Command`` or ``cli
(interface, entry_point)
| 161 | |
| 162 | |
| 163 | def _register_command_ep(interface, entry_point): |
| 164 | """Add `entry_point` command to `interface`. |
| 165 | |
| 166 | Parameters |
| 167 | ---------- |
| 168 | interface : click.Command or click.Group |
| 169 | The click interface to augment with `entry_point`. |
| 170 | entry_point : importlib.metadata.EntryPoint |
| 171 | The entry point which loads to a ``click.Command`` or |
| 172 | ``click.Group`` instance to be added as a sub-command or |
| 173 | sub-group in `interface`. |
| 174 | |
| 175 | """ |
| 176 | try: |
| 177 | command = entry_point.load() |
| 178 | except Exception as e: |
| 179 | warnings.warn( |
| 180 | f"While registering the command with name '{entry_point.name}', an " |
| 181 | f"exception occurred; {e}." |
| 182 | ) |
| 183 | return |
| 184 | if not isinstance(command, (click.Command, click.Group)): |
| 185 | warnings.warn( |
| 186 | "entry points in 'dask_cli' must be instances of " |
| 187 | f"click.Command or click.Group, not {type(command)}." |
| 188 | ) |
| 189 | return |
| 190 | |
| 191 | if command.name in interface.commands: |
| 192 | warnings.warn( |
| 193 | f"While registering the command with name '{command.name}', an " |
| 194 | "existing command or group; the original has been overwritten." |
| 195 | ) |
| 196 | |
| 197 | interface.add_command(command) |
| 198 | |
| 199 | |
| 200 | def run_cli(): |
searching dependent graphs…