Update plugins
(name: str, proxy: str | None)
| 215 | @click.argument("name", required=False) |
| 216 | @click.option("--proxy", help="GitHub proxy address") |
| 217 | def update(name: str, proxy: str | None) -> None: |
| 218 | """Update plugins""" |
| 219 | base_path = _get_data_path() |
| 220 | plug_path = base_path / "plugins" |
| 221 | plugins = build_plug_list(base_path / "plugins") |
| 222 | |
| 223 | if name: |
| 224 | plugin = next( |
| 225 | ( |
| 226 | p |
| 227 | for p in plugins |
| 228 | if p["name"] == name and p["status"] == PluginStatus.NEED_UPDATE |
| 229 | ), |
| 230 | None, |
| 231 | ) |
| 232 | |
| 233 | if not plugin: |
| 234 | raise click.ClickException( |
| 235 | f"Plugin {name} does not need updating or cannot be updated" |
| 236 | ) |
| 237 | |
| 238 | manage_plugin(plugin, plug_path, is_update=True, proxy=proxy) |
| 239 | else: |
| 240 | need_update_plugins = [ |
| 241 | p for p in plugins if p["status"] == PluginStatus.NEED_UPDATE |
| 242 | ] |
| 243 | |
| 244 | if not need_update_plugins: |
| 245 | click.echo("No plugins need updating") |
| 246 | return |
| 247 | |
| 248 | click.echo(f"Found {len(need_update_plugins)} plugin(s) needing update") |
| 249 | for plugin in need_update_plugins: |
| 250 | plugin_name = plugin["name"] |
| 251 | click.echo(f"Updating plugin {plugin_name}...") |
| 252 | manage_plugin(plugin, plug_path, is_update=True, proxy=proxy) |
| 253 | |
| 254 | |
| 255 | @plug.command() |
no test coverage detected