DockerCLI/e2e
Ian Campbell 8f3798cf04 cli-plugins: Reinstate deprecated `-h` short form of `--help`.
In the initial implementation I thought it would be good to not pass on the
deprecation to plugins (since they are new). However it turns out this causes
`docker helloworld -h` to print a spurious "pflag: help requested" line:

    $ docker helloworld -h
    pflag: help requested
    See 'docker helloworld --help'.

    Usage:	docker helloworld [OPTIONS] COMMAND

    A basic Hello World plugin for tests
    ...

Compared with:

    $ docker ps -h
    Flag shorthand -h has been deprecated, please use --help

    Usage:	docker ps [OPTIONS]

This is in essence because having the flag undefined hits a different path
within cobra, causing `c.execute()` to return early due to getting an error
(`flag.ErrHelp`) from `c.ParseFlags`, which launders the error through our
`FlagErrorFunc` which wraps it in a `StatusError` which in turn defeats an `if
err == flag.ErrHelp` check further up the call chain. If the flag is defined we
instead hit a path which returns a bare `flag.ErrHelp` without wrapping it.

I considered updating our `FlagErrorFunc` to not wrap `flag.ErrHelp` (and then
following the chain to the next thing) however while doing that I realised that
the code for `-h` (and `--help`) is deeply embedded into cobra (and its flags
library) such that actually using `-h` as a plugin argument meaning something
other than `help` is basically impossible/impractical. Therefore we may as well
have plugins behave identically to the monolithic CLI and support (deprecated)
the `-h` argument.

With this changed the help related blocks of `SetupRootCommand` and
`SetupPluginRootCommand` are now identical, so consolidate into
`setupCommonRootCommand`.

Tests are updated to check `-h` in a variety of scenarios, including the happy
case here.

Signed-off-by: Ian Campbell <ijc@docker.com>
2019-03-28 17:18:20 +00:00
..
cli-plugins cli-plugins: Reinstate deprecated `-h` short form of `--help`. 2019-03-28 17:18:20 +00:00
container Add missing test 2018-11-26 14:02:16 +00:00
image Add option to pull images quietly 2018-12-19 13:48:41 +01:00
internal/fixtures Add missing test 2018-11-26 14:02:16 +00:00
plugin Fix: plugin-tests discarding current environment 2019-03-04 20:18:24 +01:00
stack Fix some typo 2018-09-07 17:18:00 +08:00
system Update tests to use gotest.tools 👼 2018-06-08 18:24:26 +02:00
testdata e2e: avoid `usermod -p` by using `useradd`'s `--password` option 2019-03-11 14:25:41 +00:00
trust Update tests to use gotest.tools 👼 2018-06-08 18:24:26 +02:00
compose-env.connhelper-ssh.yaml connhelper: add e2e 2018-09-30 10:24:34 +09:00
compose-env.experimental.yaml Make test-e2e run against experimental and non-experimental daemon 2018-06-25 11:46:35 +02:00
compose-env.yaml Add missing test 2018-11-26 14:02:16 +00:00