Add cmdforge remove command for project dependencies
- `cmdforge remove <tool>` removes a dependency from cmdforge.yaml - Matches by exact name or short name (e.g., both "eli5" and "official/eli5" work) - Returns exit code 1 if dependency not found - Complements `cmdforge add` for full manifest management Co-Authored-By: Claude Opus 4.5 <[email protected]>
This commit is contained in:
@@ -416,6 +416,39 @@ def cmd_add(args):
|
||||
return 0
|
||||
|
||||
|
||||
def cmd_remove(args):
|
||||
"""Remove a tool from project dependencies."""
|
||||
tool_spec = args.tool
|
||||
|
||||
# Find manifest
|
||||
manifest_path = find_manifest()
|
||||
if not manifest_path:
|
||||
print("No cmdforge.yaml found in current project.")
|
||||
print("Nothing to remove.")
|
||||
return 1
|
||||
|
||||
manifest = load_manifest(manifest_path)
|
||||
|
||||
# Parse tool spec to get the name
|
||||
parsed = ToolSpec.parse(tool_spec)
|
||||
tool_name = parsed.full_name
|
||||
|
||||
# Remove from manifest
|
||||
if manifest.remove_dependency(tool_name):
|
||||
save_manifest(manifest, manifest_path)
|
||||
print(f"Removed {tool_name} from {manifest_path.name}")
|
||||
else:
|
||||
# Try without owner prefix
|
||||
if manifest.remove_dependency(parsed.name):
|
||||
save_manifest(manifest, manifest_path)
|
||||
print(f"Removed {parsed.name} from {manifest_path.name}")
|
||||
else:
|
||||
print(f"Dependency '{tool_name}' not found in {manifest_path.name}")
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
def cmd_init(args):
|
||||
"""Initialize a new cmdforge.yaml."""
|
||||
manifest_path = Path.cwd() / MANIFEST_FILENAME
|
||||
|
||||
Reference in New Issue
Block a user