[PR #15653] [CLOSED] cmd: improve CLI error messages for missing model name arguments #25736

Closed
opened 2026-04-19 18:25:15 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/15653
Author: @Vraj912
Created: 4/17/2026
Status: Closed

Base: mainHead: main


📝 Commits (2)

  • a19a140 cmd: replace generic arg errors with descriptive messages
  • e592132 cmd: add tests for arg validation

📊 Changes

2 files changed (+107 additions, -7 deletions)

View changed files

📝 cmd/cmd.go (+34 -7)
📝 cmd/cmd_test.go (+73 -0)

📄 Description

Summary

Replaces generic argument validation errors with descriptive messages for the following commands:

  • ollama create
  • ollama show
  • ollama stop
  • ollama pull
  • ollama push
  • ollama cp

Before

Error: accepts 1 arg(s), received 0

After

Error: missing model name

For ollama cp, the error now reads: missing source and/or destination model name

When extra arguments are provided, all commands now return: extra arguments

Motivation

Users running commands like ollama show without specifying a model receive unclear error messages. Clear error messages improve UX and help users quickly understand and fix their
mistakes.

Testing

Added unit tests in cmd/cmd_test.go:

  • TestValidateModelNameArg - tests single-arg validation
  • TestValidateModelNameArgs - tests two-arg validation (cp command)

Closes #2893


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/15653 **Author:** [@Vraj912](https://github.com/Vraj912) **Created:** 4/17/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (2) - [`a19a140`](https://github.com/ollama/ollama/commit/a19a14050785d53c4f207d296e88f0866da5edd0) cmd: replace generic arg errors with descriptive messages - [`e592132`](https://github.com/ollama/ollama/commit/e59213273e053794cfec8a6fc7db71c09542637d) cmd: add tests for arg validation ### 📊 Changes **2 files changed** (+107 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `cmd/cmd.go` (+34 -7) 📝 `cmd/cmd_test.go` (+73 -0) </details> ### 📄 Description ## Summary Replaces generic argument validation errors with descriptive messages for the following commands: - `ollama create` - `ollama show` - `ollama stop` - `ollama pull` - `ollama push` - `ollama cp` ### Before Error: accepts 1 arg(s), received 0 ### After Error: missing model name For `ollama cp`, the error now reads: `missing source and/or destination model name` When extra arguments are provided, all commands now return: `extra arguments` ## Motivation Users running commands like `ollama show` without specifying a model receive unclear error messages. Clear error messages improve UX and help users quickly understand and fix their mistakes. ## Testing Added unit tests in `cmd/cmd_test.go`: - `TestValidateModelNameArg` - tests single-arg validation - `TestValidateModelNameArgs` - tests two-arg validation (cp command) ## Related Issue Closes #2893 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-19 18:25:15 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#25736