Skip to content

Show long help message when defined#1098

Merged
silvin-lubecki merged 1 commit intodocker:masterfrom
dhiltgen:long_help
Aug 30, 2018
Merged

Show long help message when defined#1098
silvin-lubecki merged 1 commit intodocker:masterfrom
dhiltgen:long_help

Conversation

@dhiltgen
Copy link
Contributor

This fixes the help template so that if a command
includes a Long form help message that is displayed instead
of ignoring it and always showing the Short message.

Signed-off-by: Daniel Hiltgen daniel.hiltgen@docker.com

For example:
https://github.com/docker/cli/blob/master/cli/command/container/cp.go#L49-L56

Before this fix:

% docker container cp --help

Usage:	docker container cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-
	docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH

Copy files/folders between a container and the local filesystem

Options:
  -a, --archive       Archive mode (copy all uid/gid information)
  -L, --follow-link   Always follow symbol link in SRC_PATH

After this fix

% docker container cp --help

Usage:	docker container cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-
	docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH

Copy files/folders between a container and the local filesystem

Use '-' as the source to read a tar archive from stdin
and extract it to a directory destination in a container.
Use '-' as the destination to stream a tar archive of a
container source to stdout.

Options:
  -a, --archive               Archive mode (copy all uid/gid information)
  -L, --follow-link           Always follow symbol link in SRC_PATH
      --orchestrator string   Orchestrator to use (swarm|kubernetes|all)

(The orchestrator flag is a bug recently introduced - unrelated to this PR)

This fixes the help template so that if a command
includes a Long form help message that is displayed instead
of ignoring it and always showing the Short message.

Signed-off-by: Daniel Hiltgen <daniel.hiltgen@docker.com>
@dhiltgen
Copy link
Contributor Author

dhiltgen commented May 31, 2018

I should note that the --help on the parent command still lists the Short message as it should

% docker container --help

Usage:	docker container COMMAND

Manage containers

Options:
      --orchestrator string   Orchestrator to use (swarm|kubernetes|all)

Commands:
  attach      Attach local standard input, output, and error streams to a running container
  commit      Create a new image from a container's changes
  cp          Copy files/folders between a container and the local filesystem
  create      Create a new container
...

{{- if .HasSubCommands}} {{ .CommandPath}} COMMAND{{end}}

{{ .Short | trim }}
{{if ne .Long ""}}{{ .Long | trim }}{{ else }}{{ .Short | trim }}{{end}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this was changed in https://github.com/moby/moby/pull/23825/files#diff-4a2b6f090171fe18f7406cb69fb2e479R143

The original template was;

{{with or .Long .Short }}{{. | trim}}{{end}}{{if gt .Aliases 0}}

In a later PR, man-page generation was moved to external markdown files; moby/moby#26830, but the template wasn't updated with that change, so I think it's ok to use the long description again (if present)

ping @dnephin to double check

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya, seems fine to use Long now

Copy link
Contributor

@silvin-lubecki silvin-lubecki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@silvin-lubecki silvin-lubecki merged commit 1546d71 into docker:master Aug 30, 2018
@GordonTheTurtle GordonTheTurtle added this to the 18.09.0 milestone Aug 30, 2018
silvin-lubecki added a commit to silvin-lubecki/app that referenced this pull request Sep 4, 2018
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants