[PR #15773] cmd: show help when stop and show are called without a model argument #61999

Open
opened 2026-04-29 16:57:23 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/15773
Author: @anishesg
Created: 4/23/2026
Status: 🔄 Open

Base: mainHead: fix/ph-issue-15769


📝 Commits (1)

  • 20e933d cmd: show help when stop and show are called without a model argument

📊 Changes

1 file changed (+27 additions, -10 deletions)

View changed files

📝 cmd/cmd.go (+27 -10)

📄 Description

ollama stop and ollama show both use cobra.ExactArgs(1), which causes cobra to return the unhelpful error "accepts 1 arg(s), received 0" when the user runs either command without a model name. This is confusing because the user does not see the command's usage text.

The fix changes both commands to use cobra.MaximumNArgs(1) and adds an early return in StopHandler and ShowHandler that prints the command help when no arguments are provided. The PreRunE server heartbeat check is also skipped when no args are given, so users don't get a spurious server connection error before seeing the help text.

Tested manually: ollama stop and ollama show without arguments now print the usage text instead of erroring, while ollama stop <model> and ollama show <model> continue to work correctly.

Fixes #15769


🔄 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/15773 **Author:** [@anishesg](https://github.com/anishesg) **Created:** 4/23/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/ph-issue-15769` --- ### 📝 Commits (1) - [`20e933d`](https://github.com/ollama/ollama/commit/20e933d12f222816b231be2cc8b0743cecacd79c) cmd: show help when stop and show are called without a model argument ### 📊 Changes **1 file changed** (+27 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `cmd/cmd.go` (+27 -10) </details> ### 📄 Description `ollama stop` and `ollama show` both use `cobra.ExactArgs(1)`, which causes cobra to return the unhelpful error "accepts 1 arg(s), received 0" when the user runs either command without a model name. This is confusing because the user does not see the command's usage text. The fix changes both commands to use `cobra.MaximumNArgs(1)` and adds an early return in `StopHandler` and `ShowHandler` that prints the command help when no arguments are provided. The `PreRunE` server heartbeat check is also skipped when no args are given, so users don't get a spurious server connection error before seeing the help text. Tested manually: `ollama stop` and `ollama show` without arguments now print the usage text instead of erroring, while `ollama stop <model>` and `ollama show <model>` continue to work correctly. Fixes #15769 --- <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-29 16:57:23 -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#61999