add model remove cli command

This commit is contained in:
leonardotrapani
2026-02-01 01:22:53 +01:00
parent 61b2db53bc
commit c05a3c8c2a
3 changed files with 49 additions and 2 deletions
+39
View File
@@ -405,6 +405,7 @@ func modelCmd() *cobra.Command {
cmd.AddCommand(modelListCmd()) cmd.AddCommand(modelListCmd())
cmd.AddCommand(modelDownloadCmd()) cmd.AddCommand(modelDownloadCmd())
cmd.AddCommand(modelRemoveCmd())
return cmd return cmd
} }
@@ -586,3 +587,41 @@ func runModelDownload(ctx context.Context, modelName string) error {
fmt.Printf("\ndownload complete: %s\n", path) fmt.Printf("\ndownload complete: %s\n", path)
return nil return nil
} }
func modelRemoveCmd() *cobra.Command {
return &cobra.Command{
Use: "remove <model-name>",
Short: "Remove a downloaded local model",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
return runModelRemove(args[0])
},
}
}
func runModelRemove(modelName string) error {
// find the model across all providers
model, _, err := provider.FindModelByID(modelName)
if err != nil {
return fmt.Errorf("unknown model: %s", modelName)
}
// check if it's a cloud model (nothing to remove)
if !model.NeedsDownload() {
fmt.Printf("model '%s' is a cloud model, nothing to remove\n", modelName)
return nil
}
// check if installed
if !whisper.IsInstalled(modelName) {
return fmt.Errorf("model '%s' is not installed", modelName)
}
// remove the model
if err := whisper.Remove(modelName); err != nil {
return fmt.Errorf("failed to remove model: %w", err)
}
fmt.Printf("model '%s' removed successfully\n", modelName)
return nil
}
+9 -1
View File
@@ -255,4 +255,12 @@ Started: Sun Feb 1 12:22:47 AM CET 2026
- Downloads with progress callback showing percentage (10%, 20%, ...) - Downloads with progress callback showing percentage (10%, 20%, ...)
- Prints success message with full model path - Prints success message with full model path
- Tested: cloud model rejection, unknown model error, download with progress, already installed - Tested: cloud model rejection, unknown model error, download with progress, already installed
- All tests passing, typecheck passes - All tests passing, typecheck passes
### Task 26: Add model remove CLI command
- Created `modelRemoveCmd()` subcommand with Use: 'remove <model-name>'
- Uses `provider.FindModelByID()` to find model across all providers
- Cloud models: prints 'nothing to remove'
- Not installed: returns error 'model is not installed'
- Installed: calls `whisper.Remove()`, prints success message
- All verification scenarios tested, typecheck passes
+1 -1
View File
@@ -616,7 +616,7 @@
"Shows success message after removal", "Shows success message after removal",
"Typecheck passes" "Typecheck passes"
], ],
"passes": false "passes": true
}, },
// ============================================================================ // ============================================================================
// PHASE 6: TUI IMPROVEMENTS // PHASE 6: TUI IMPROVEMENTS