Skip to content

Commit af4e312

Browse files
committed
add command to update plugin
1 parent f7910f0 commit af4e312

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/faff_cli/plugin.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,40 @@ def list_plugins(ctx: typer.Context):
138138
if instances:
139139
typer.echo(f" Instances: {', '.join(sorted(instances))}")
140140

141+
@app.command()
142+
def update(
143+
ctx: typer.Context,
144+
plugin_name: str = typer.Argument(..., help="Name of the plugin to update")
145+
):
146+
"""
147+
Update an installed plugin by pulling the latest changes from its GitHub repository.
148+
"""
149+
ws: Workspace = ctx.obj
150+
151+
plugins_dir = Path(ws.storage().base_dir()) / "plugins"
152+
plugin_dir = plugins_dir / plugin_name
153+
154+
if not plugin_dir.exists():
155+
typer.echo(f"Plugin '{plugin_name}' is not installed.", err=True)
156+
raise typer.Exit(1)
157+
158+
typer.echo(f"Updating plugin '{plugin_name}'...")
159+
160+
try:
161+
# Pull the latest changes
162+
result = subprocess.run(
163+
["git", "-C", str(plugin_dir), "pull"],
164+
check=True,
165+
capture_output=True,
166+
text=True
167+
)
168+
169+
typer.echo(result.stdout)
170+
typer.echo(f"✓ Successfully updated plugin '{plugin_name}'")
171+
172+
except subprocess.CalledProcessError as e:
173+
typer.echo(f"Error updating plugin: {e.stderr}", err=True)
174+
raise typer.Exit(1)
141175

142176
@app.command()
143177
def uninstall(

0 commit comments

Comments
 (0)