delete all models (not just 1st) in ollama rm (#415)

Previously, `ollama rm model1 model2 modelN` would only delete `model1`. The other model command-line arguments would be silently ignored. Now, all models mentioned are deleted.
This commit is contained in:
Quinn Slack 2023-08-26 00:47:56 -07:00 committed by GitHub
parent ee6e1df118
commit 2ecc3a33c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -220,11 +220,13 @@ func DeleteHandler(cmd *cobra.Command, args []string) error {
return err
}
req := api.DeleteRequest{Name: args[0]}
if err := client.Delete(context.Background(), &req); err != nil {
return err
for _, name := range args {
req := api.DeleteRequest{Name: name}
if err := client.Delete(context.Background(), &req); err != nil {
return err
}
fmt.Printf("deleted '%s'\n", name)
}
fmt.Printf("deleted '%s'\n", args[0])
return nil
}