Install a plugin
(name: str | None, local_path: Path | None, proxy: str | None)
| 154 | ) |
| 155 | @click.option("--proxy", help="Proxy server address") |
| 156 | def install(name: str | None, local_path: Path | None, proxy: str | None) -> None: |
| 157 | """Install a plugin""" |
| 158 | base_path = _get_data_path() |
| 159 | plug_path = base_path / "plugins" |
| 160 | |
| 161 | if local_path is not None: |
| 162 | install_local_plugin(local_path, plug_path, editable=True) |
| 163 | return |
| 164 | |
| 165 | if name is None: |
| 166 | raise click.ClickException("Missing plugin name or local plugin path") |
| 167 | |
| 168 | local_name_path = Path(name).expanduser() |
| 169 | if local_name_path.exists() and local_name_path.is_dir(): |
| 170 | install_local_plugin(local_name_path, plug_path, editable=False) |
| 171 | return |
| 172 | |
| 173 | plugins = build_plug_list(base_path / "plugins") |
| 174 | |
| 175 | plugin = next( |
| 176 | ( |
| 177 | p |
| 178 | for p in plugins |
| 179 | if p["name"] == name and p["status"] == PluginStatus.NOT_INSTALLED |
| 180 | ), |
| 181 | None, |
| 182 | ) |
| 183 | |
| 184 | if not plugin: |
| 185 | raise click.ClickException(f"Plugin {name} not found or already installed") |
| 186 | |
| 187 | manage_plugin(plugin, plug_path, is_update=False, proxy=proxy) |
| 188 | |
| 189 | |
| 190 | @plug.command() |
nothing calls this directly
no test coverage detected