Skip to content

cmd: report unknown command before unknown flag - #7291

Open
locker95 wants to merge 2 commits into
docker:masterfrom
locker95:fix/unknown-cmd-before-flag
Open

cmd: report unknown command before unknown flag#7291
locker95 wants to merge 2 commits into
docker:masterfrom
locker95:fix/unknown-cmd-before-flag

Conversation

@locker95

@locker95 locker95 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

docker iamges --filter was coming back as unknown flag: --filter because the root command kept parsing flags after the first token.

stop at the first non-flag so this matches docker iamges and says the command is unknown.

Fixes #4550

`docker iamges --filter` was coming back as unknown flag because the
root command kept parsing flags after the first token.

Stop at the first non-flag so this matches `docker iamges` and says
the command is unknown.

Fixes docker#4550

Signed-off-by: Dean Chen <862469039@qq.com>
@codecov-commenter

codecov-commenter commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 52.94118% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/docker/docker.go 52.94% 4 Missing and 4 partials ⚠️

📢 Thoughts on this report? Let us know!

SetInterspersed(false) made `docker nonexistent --help` fail instead
of printing the root help. Rewrite unknown-flag errors only when the
first leftover arg isn't a subcommand.

Fixes docker#4550

Signed-off-by: Dean Chen <862469039@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI returns "unknown flag" error when you misspell a command and pass a flag

2 participants