docker / app

Make your Docker Compose applications reusable, and share them on Docker Hub
Apache License 2.0
1.58k stars 177 forks source link

Return exit code 1 & usage message when an unknown command is passed … #635

Closed glours closed 4 years ago

glours commented 4 years ago

- What I did Return the usage message and 1 as return code when a bad command is passed to the CLI

- How I did it remove the empty case on completion switch call to the command help function return a error with this format "unknown command: %s", strings.Join(args," ")

- How to verify it

- A picture of a cute animal (not mandatory but encouraged) bear2

glours commented 4 years ago

There is a different behavior between the unknown flag & command, the flag is displayed before the usage message and after for an unknown command (because we need to finish by error to trigger an exit 1) A solution to have a similar behavior will be to do os.Exit(1) directly without sending the error to the CLI plugin WDYT?

rumpl commented 4 years ago

To be more in line with what the cli is doing we should maybe:

The cli does this:

$ docker asdf
docker: 'asdf' is not a docker command.
See 'docker --help'
glours commented 4 years ago

@rumpl add the error message on the top before the usage message & return the status code 1 with an os.Exit(1) Maybe it's good enough to mark the PR as Ready for review?

codecov[bot] commented 4 years ago

Codecov Report

Merging #635 into master will decrease coverage by 0.1%. The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #635      +/-   ##
==========================================
- Coverage   71.93%   71.83%   -0.11%     
==========================================
  Files          49       49              
  Lines        2544     2549       +5     
==========================================
+ Hits         1830     1831       +1     
- Misses        483      488       +5     
+ Partials      231      230       -1
Impacted Files Coverage Δ
internal/commands/root.go 69% <0%> (-4.53%) :arrow_down:
internal/commands/push.go 45.68% <0%> (+0.27%) :arrow_up:
internal/commands/install.go 66.66% <0%> (+0.46%) :arrow_up:
internal/commands/render.go 81.25% <0%> (+0.6%) :arrow_up:
internal/commands/upgrade.go 59.64% <0%> (+0.72%) :arrow_up:
internal/commands/inspect.go 81.81% <0%> (+0.86%) :arrow_up:
internal/commands/pull.go 70.37% <0%> (+2.37%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update d8b439a...351e8cd. Read the comment docs.