diff --git a/docs/ramalama-rm.1.md b/docs/ramalama-rm.1.md index 8fcbe98c..faadb683 100644 --- a/docs/ramalama-rm.1.md +++ b/docs/ramalama-rm.1.md @@ -4,10 +4,10 @@ ramalama\-rm - remove AI Models from local storage ## SYNOPSIS -**ramalama rm** [*options*] *model* +**ramalama rm** [*options*] *model* [...] ## DESCRIPTION -remove AI Model from local storage +Specity one or more AI Models to be removed from local storage ## OPTIONS diff --git a/ramalama/cli.py b/ramalama/cli.py index 978a5f4a..81cff3eb 100644 --- a/ramalama/cli.py +++ b/ramalama/cli.py @@ -503,26 +503,26 @@ def rm_parser(subparsers): parser = subparsers.add_parser("rm", help="remove AI Model from local storage") parser.add_argument("-a", "--all", action="store_true", help="remove all local Models") parser.add_argument("--ignore", action="store_true", help="ignore errors when specified Model does not exist") - parser.add_argument("MODEL", nargs="?") + parser.add_argument("MODELS", nargs="*") parser.set_defaults(func=rm_cli) -def _rm_model(model, args): - model = New(model) - model.remove(args) +def _rm_model(models, args): + for model in models: + model = New(model) + model.remove(args) def rm_cli(args): if not args.all: - return _rm_model(args.MODEL, args) + return _rm_model(args.MODELS, args) - if args.MODEL == "": + if len(args.MODELS) > 0: raise IndexError("can not specify --all as well MODEL") args.noheading = True - for model in _list_models(args): - _rm_model(model["name"], args) - + models = [k['name'] for k in _list_models(args) ] + _rm_model(models, args) def get_store(): if os.geteuid() == 0: diff --git a/test/system/050-pull.bats b/test/system/050-pull.bats index bcabd067..792f4d8e 100644 --- a/test/system/050-pull.bats +++ b/test/system/050-pull.bats @@ -19,8 +19,7 @@ load helpers run_ramalama pull ollama://tinyllama:1.1b run_ramalama list is "$output" ".*ollama://tinyllama:1.1b" "image was actually pulled locally" - run_ramalama rm ollama://tinyllama - run_ramalama rm ollama://tinyllama:1.1b + run_ramalama rm ollama://tinyllama ollama://tinyllama:1.1b } # bats test_tags=distro-integration