Closed glours closed 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?
To be more in line with what the cli is doing we should maybe:
'titi' is not a docker app command
The cli does this:
$ docker asdf
docker: 'asdf' is not a docker command.
See 'docker --help'
@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?
Merging #635 into master will decrease coverage by
0.1%
. The diff coverage is0%
.
@@ 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.
- 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
docker app
, check it displays the usage message & check the return code is 0 withecho $?
docker app unknown_command
, check it displays the usage message & check the return code is 1 withecho $?
- A picture of a cute animal (not mandatory but encouraged)![bear2](https://user-images.githubusercontent.com/705411/65517935-c7a60700-dee3-11e9-9ad2-38d57b2ab1a7.jpeg)