Skip to content

Commit

Permalink
Merge pull request containers#2309 from rhatdan/help
Browse files Browse the repository at this point in the history
Don't show global flags except for podman command
  • Loading branch information
openshift-merge-robot authored Feb 12, 2019
2 parents faafdcf + ccbc4fb commit bdf537f
Show file tree
Hide file tree
Showing 80 changed files with 122 additions and 21 deletions.
1 change: 1 addition & 0 deletions cmd/podman/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var (

func init() {
attachCommand.Command = _attachCommand
attachCommand.SetUsageTemplate(UsageTemplate())
flags := attachCommand.Flags()
flags.StringVar(&attachCommand.DetachKeys, "detach-keys", "", "Override the key sequence for detaching a container. Format is a single character [a-Z] or ctrl-<value> where <value> is one of: a-z, @, ^, [, , or _")
flags.BoolVar(&attachCommand.NoStdin, "no-stdin", false, "Do not attach STDIN. The default is false")
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ var (

func init() {
buildCommand.Command = _buildCommand
buildCommand.SetUsageTemplate(UsageTemplate())
flags := buildCommand.Flags()
flags.SetInterspersed(false)

Expand Down
1 change: 1 addition & 0 deletions cmd/podman/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var (

func init() {
checkpointCommand.Command = _checkpointCommand
checkpointCommand.SetUsageTemplate(UsageTemplate())

flags := checkpointCommand.Flags()
flags.BoolVarP(&checkpointCommand.Keep, "keep", "k", false, "Keep all temporary checkpoint files")
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var (

func init() {
cleanupCommand.Command = _cleanupCommand
cleanupCommand.SetUsageTemplate(UsageTemplate())
flags := cleanupCommand.Flags()

flags.BoolVarP(&cleanupCommand.All, "all", "a", false, "Cleans up all containers")
Expand Down
4 changes: 2 additions & 2 deletions cmd/podman/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func getMainCommands() []*cobra.Command {
_restartCommand,
_restoreCommand,
_rmCommand,
_runCommmand,
_runCommand,
_saveCommand,
_searchCommand,
_signCommand,
Expand Down Expand Up @@ -82,7 +82,7 @@ func getContainerSubCommands() []*cobra.Command {
_restartCommand,
_restoreCommand,
_rmCommand,
_runCommmand,
_runCommand,
_runlabelCommand,
_startCommand,
_statsCommand,
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var (

func init() {
commitCommand.Command = _commitCommand
commitCommand.SetUsageTemplate(UsageTemplate())
flags := commitCommand.Flags()
flags.StringSliceVarP(&commitCommand.Change, "change", "c", []string{}, fmt.Sprintf("Apply the following possible instructions to the created image (default []): %s", strings.Join(libpod.ChangeCmds, " | ")))
flags.StringVarP(&commitCommand.Format, "format", "f", "oci", "`Format` of the image manifest and metadata")
Expand Down
24 changes: 24 additions & 0 deletions cmd/podman/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,3 +500,27 @@ func scrubServer(server string) string {
server = strings.TrimPrefix(server, "https://")
return strings.TrimPrefix(server, "http://")
}

// UsageTemplate returns the usage template for podman commands
// This blocks the desplaying of the global options. The main podman
// command should not use this.
func UsageTemplate() string {
return `Usage:{{if .Runnable}}
{{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
{{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}
Aliases:
{{.NameAndAliases}}{{end}}{{if .HasExample}}
Examples:
{{.Example}}{{end}}{{if .HasAvailableSubCommands}}
Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}
Flags:
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}
{{end}}
`
}
1 change: 1 addition & 0 deletions cmd/podman/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ var containerCommands = []*cobra.Command{
func init() {
containerCommand.AddCommand(containerCommands...)
containerCommand.AddCommand(getContainerSubCommands()...)
containerCommand.SetUsageTemplate(UsageTemplate())
rootCmd.AddCommand(containerCommand.Command)
}
1 change: 1 addition & 0 deletions cmd/podman/containers_prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var (

func init() {
pruneContainersCommand.Command = _pruneContainersCommand
pruneContainersCommand.SetUsageTemplate(UsageTemplate())
}

func pruneContainers(runtime *adapter.LocalRuntime, ctx context.Context, maxWorkers int, force bool) error {
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ var (

func init() {
createCommand.PodmanCommand.Command = _createCommand
createCommand.SetUsageTemplate(UsageTemplate())

getCreateFlags(&createCommand.PodmanCommand)
flags := createCommand.Flags()
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ var (

func init() {
diffCommand.Command = _diffCommand
diffCommand.SetUsageTemplate(UsageTemplate())
flags := diffCommand.Flags()

flags.BoolVar(&diffCommand.Archive, "archive", true, "Save the diff as a tar archive")
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var (

func init() {
execCommand.Command = _execCommand
execCommand.SetUsageTemplate(UsageTemplate())
flags := execCommand.Flags()
flags.SetInterspersed(false)
flags.StringSliceVarP(&execCommand.Env, "env", "e", []string{}, "Set environment variables")
Expand Down
3 changes: 3 additions & 0 deletions cmd/podman/exists.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ var (

func init() {
imageExistsCommand.Command = _imageExistsCommand
imageExistsCommand.SetUsageTemplate(UsageTemplate())
containerExistsCommand.Command = _containerExistsCommand
containerExistsCommand.SetUsageTemplate(UsageTemplate())
podExistsCommand.Command = _podExistsCommand
podExistsCommand.SetUsageTemplate(UsageTemplate())
}

func imageExistsCmd(c *cliconfig.ImageExistsValues) error {
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var (

func init() {
exportCommand.Command = _exportCommand
exportCommand.SetUsageTemplate(UsageTemplate())
flags := exportCommand.Flags()
flags.StringVarP(&exportCommand.Output, "output", "o", "/dev/stdout", "Write to a file, default is STDOUT")
}
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ var generateCommand = cliconfig.PodmanCommand{

func init() {
generateCommand.AddCommand(getGenerateSubCommands()...)
generateCommand.SetUsageTemplate(UsageTemplate())
}
1 change: 1 addition & 0 deletions cmd/podman/generate_kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var (

func init() {
containerKubeCommand.Command = _containerKubeCommand
containerKubeCommand.SetUsageTemplate(UsageTemplate())
flags := containerKubeCommand.Flags()
flags.BoolVarP(&containerKubeCommand.Service, "service", "s", false, "Generate YAML for kubernetes service object")
}
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ var (

func init() {
historyCommand.Command = _historyCommand
historyCommand.SetUsageTemplate(UsageTemplate())
flags := historyCommand.Flags()
flags.StringVar(&historyCommand.Format, "format", "", "Change the output to JSON or a Go template")
flags.BoolVarP(&historyCommand.Human, "human", "H", true, "Display sizes and dates in human readable format")
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var imageSubCommands = []*cobra.Command{
}

func init() {
imageCommand.SetUsageTemplate(UsageTemplate())
imageCommand.AddCommand(imageSubCommands...)
imageCommand.AddCommand(getImageSubCommands()...)
}
1 change: 1 addition & 0 deletions cmd/podman/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ var (

func init() {
imagesCommand.Command = _imagesCommand
imagesCommand.SetUsageTemplate(UsageTemplate())
flags := imagesCommand.Flags()
flags.BoolVarP(&imagesCommand.All, "all", "a", false, "Show all images (default hides intermediate images)")
flags.BoolVar(&imagesCommand.Digests, "digests", false, "Show digests")
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/images_prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var (

func init() {
pruneImagesCommand.Command = _pruneImagesCommand
pruneImagesCommand.SetUsageTemplate(UsageTemplate())
flags := pruneImagesCommand.Flags()
flags.BoolVarP(&pruneImagesCommand.All, "all", "a", false, "Remove all unused images, not just dangling ones")
}
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var (

func init() {
importCommand.Command = _importCommand
importCommand.SetUsageTemplate(UsageTemplate())
flags := importCommand.Flags()
flags.StringSliceVarP(&importCommand.Change, "change", "c", []string{}, "Apply the following possible instructions to the created image (default []): CMD | ENTRYPOINT | ENV | EXPOSE | LABEL | STOPSIGNAL | USER | VOLUME | WORKDIR")
flags.StringVarP(&importCommand.Message, "message", "m", "", "Set commit message for imported image")
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var (

func init() {
infoCommand.Command = _infoCommand
infoCommand.SetUsageTemplate(UsageTemplate())
flags := infoCommand.Flags()

flags.BoolVarP(&infoCommand.Debug, "debug", "D", false, "Display additional debug information")
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var (

func init() {
inspectCommand.Command = _inspectCommand
inspectCommand.SetUsageTemplate(UsageTemplate())
flags := inspectCommand.Flags()
flags.StringVarP(&inspectCommand.TypeObject, "type", "t", inspectAll, "Return JSON for specified type, (e.g image, container or task)")
flags.StringVarP(&inspectCommand.Format, "format", "f", "", "Change the output format to a Go template")
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var (

func init() {
killCommand.Command = _killCommand
killCommand.SetUsageTemplate(UsageTemplate())
flags := killCommand.Flags()

flags.BoolVarP(&killCommand.All, "all", "a", false, "Signal all running containers")
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var (

func init() {
loadCommand.Command = _loadCommand
loadCommand.SetUsageTemplate(UsageTemplate())
flags := loadCommand.Flags()
flags.StringVarP(&loadCommand.Input, "input", "i", "/dev/stdin", "Read from archive file, default is STDIN")
flags.BoolVarP(&loadCommand.Quiet, "quiet", "q", false, "Suppress the output")
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var (

func init() {
loginCommand.Command = _loginCommand
loginCommand.SetUsageTemplate(UsageTemplate())
flags := loginCommand.Flags()

flags.StringVar(&loginCommand.Authfile, "authfile", "", "Path of the authentication file. Default is ${XDG_RUNTIME_DIR}/containers/auth.json. Use REGISTRY_AUTH_FILE environment variable to override")
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var (

func init() {
logoutCommand.Command = _logoutCommand
logoutCommand.SetUsageTemplate(UsageTemplate())
flags := logoutCommand.Flags()
flags.BoolVarP(&logoutCommand.All, "all", "a", false, "Remove the cached credentials for all registries in the auth file")
flags.StringVar(&logoutCommand.Authfile, "authfile", "", "Path of the authentication file. Default is ${XDG_RUNTIME_DIR}/containers/auth.json. Use REGISTRY_AUTH_FILE environment variable to override")
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var (

func init() {
logsCommand.Command = _logsCommand
logsCommand.SetUsageTemplate(UsageTemplate())
flags := logsCommand.Flags()
flags.BoolVar(&logsCommand.Details, "details", false, "Show extra details provided to the logs")
flags.BoolVarP(&logsCommand.Follow, "follow", "f", false, "Follow log output. The default is false")
Expand Down
4 changes: 2 additions & 2 deletions cmd/podman/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ var cmdsNotRequiringRootless = map[*cobra.Command]bool{
_killCommand: true,
_pauseCommand: true,
_restartCommand: true,
_runCommmand: true,
_runCommand: true,
_unpauseCommand: true,
_searchCommand: true,
_statsCommand: true,
Expand Down Expand Up @@ -205,7 +205,7 @@ func main() {
exitCode = status.ExitStatus()
}
}
fmt.Fprintln(os.Stderr, err.Error())
fmt.Fprintln(os.Stderr, "Error:", err.Error())
}
} else {
// The exitCode modified from 125, indicates an application
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var (

func init() {
mountCommand.Command = _mountCommand
mountCommand.SetUsageTemplate(UsageTemplate())
flags := mountCommand.Flags()
flags.BoolVarP(&mountCommand.All, "all", "a", false, "Mount all containers")
flags.StringVar(&mountCommand.Format, "format", "", "Change the output format to Go template")
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/pause.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var (

func init() {
pauseCommand.Command = _pauseCommand
pauseCommand.SetUsageTemplate(UsageTemplate())
flags := pauseCommand.Flags()
flags.BoolVarP(&pauseCommand.All, "all", "a", false, "Pause all running containers")

Expand Down
14 changes: 7 additions & 7 deletions cmd/podman/play.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ import (
"github.com/spf13/cobra"
)

var playCommand cliconfig.PodmanCommand

func init() {
var playDescription = "Play a pod and its containers from a structured file."
playCommand.Command = &cobra.Command{
var (
playCommand cliconfig.PodmanCommand
playDescription = "Play a pod and its containers from a structured file."
_playCommand = &cobra.Command{
Use: "play",
Short: "Play a pod",
Long: playDescription,
}

}
)

func init() {
playCommand.Command = _playCommand
playCommand.SetUsageTemplate(UsageTemplate())
playCommand.AddCommand(getPlaySubCommands()...)
}
1 change: 1 addition & 0 deletions cmd/podman/play_kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ var (

func init() {
playKubeCommand.Command = _playKubeCommand
playKubeCommand.SetUsageTemplate(UsageTemplate())
flags := playKubeCommand.Flags()
flags.StringVar(&playKubeCommand.Authfile, "authfile", "", "Path of the authentication file. Default is ${XDG_RUNTIME_DIR}/containers/auth.json. Use REGISTRY_AUTH_FILE environment variable to override")
flags.StringVar(&playKubeCommand.CertDir, "cert-dir", "", "`Pathname` of a directory containing TLS certificates and keys")
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ var podCommand = cliconfig.PodmanCommand{

func init() {
podCommand.AddCommand(getPodSubCommands()...)
podCommand.SetUsageTemplate(UsageTemplate())
}
1 change: 1 addition & 0 deletions cmd/podman/pod_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var (

func init() {
podCreateCommand.Command = _podCreateCommand
podCreateCommand.SetUsageTemplate(UsageTemplate())
flags := podCreateCommand.Flags()
flags.SetInterspersed(false)

Expand Down
1 change: 1 addition & 0 deletions cmd/podman/pod_inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var (

func init() {
podInspectCommand.Command = _podInspectCommand
podInspectCommand.SetUsageTemplate(UsageTemplate())
flags := podInspectCommand.Flags()
flags.BoolVarP(&podInspectCommand.Latest, "latest", "l", false, "Act on the latest container podman is aware of")

Expand Down
1 change: 1 addition & 0 deletions cmd/podman/pod_kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var (

func init() {
podKillCommand.Command = _podKillCommand
podKillCommand.SetUsageTemplate(UsageTemplate())
flags := podKillCommand.Flags()
flags.BoolVarP(&podKillCommand.All, "all", "a", false, "Kill all containers in all pods")
flags.BoolVarP(&podKillCommand.Latest, "latest", "l", false, "Act on the latest pod podman is aware of")
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/pod_pause.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var (

func init() {
podPauseCommand.Command = _podPauseCommand
podPauseCommand.SetUsageTemplate(UsageTemplate())
flags := podPauseCommand.Flags()
flags.BoolVarP(&podPauseCommand.All, "all", "a", false, "Pause all running pods")
flags.BoolVarP(&podPauseCommand.Latest, "latest", "l", false, "Act on the latest pod podman is aware of")
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/pod_ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ var (

func init() {
podPsCommand.Command = _podPsCommand
podPsCommand.SetUsageTemplate(UsageTemplate())
flags := podPsCommand.Flags()
flags.BoolVar(&podPsCommand.CtrNames, "ctr-names", false, "Display the container names")
flags.BoolVar(&podPsCommand.CtrIDs, "ctr-ids", false, "Display the container UUIDs. If no-trunc is not set they will be truncated")
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/pod_restart.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var (

func init() {
podRestartCommand.Command = _podRestartCommand
podRestartCommand.SetUsageTemplate(UsageTemplate())
flags := podRestartCommand.Flags()
flags.BoolVarP(&podRestartCommand.All, "all", "a", false, "Restart all running pods")
flags.BoolVarP(&podRestartCommand.Latest, "latest", "l", false, "Restart the latest pod podman is aware of")
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/pod_rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ If --force is specified, all containers will be stopped, then removed.

func init() {
podRmCommand.Command = _podRmCommand
podRmCommand.SetUsageTemplate(UsageTemplate())
flags := podRmCommand.Flags()
flags.BoolVarP(&podRmCommand.All, "all", "a", false, "Remove all running pods")
flags.BoolVarP(&podRmCommand.Force, "force", "f", false, "Force removal of a running pod by first stopping all containers, then removing all containers in the pod. The default is false")
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/pod_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var (

func init() {
podStartCommand.Command = _podStartCommand
podStartCommand.SetUsageTemplate(UsageTemplate())
flags := podStartCommand.Flags()
flags.BoolVarP(&podStartCommand.All, "all", "a", false, "Start all pods")
flags.BoolVarP(&podStartCommand.Latest, "latest", "l", false, "Start the latest pod podman is aware of")
Expand Down
Loading

0 comments on commit bdf537f

Please sign in to comment.