Skip to content

Commit

Permalink
Merge pull request containers#2564 from rhatdan/cleanup
Browse files Browse the repository at this point in the history
Fix help commands to show short and long description.
  • Loading branch information
openshift-merge-robot authored Mar 7, 2019
2 parents 1b253cf + 9a39c60 commit 94e89fc
Show file tree
Hide file tree
Showing 75 changed files with 245 additions and 200 deletions.
1 change: 1 addition & 0 deletions cmd/podman/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var (

func init() {
attachCommand.Command = _attachCommand
attachCommand.SetHelpTemplate(HelpTemplate())
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 _")
Expand Down
4 changes: 2 additions & 2 deletions cmd/podman/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import (

var (
buildCommand cliconfig.BuildValues
buildDescription = "Builds an OCI or Docker image using instructions from one\n" +
"or more Dockerfiles and a specified build context directory."
buildDescription = "Builds an OCI or Docker image using instructions from one or more Dockerfiles and a specified build context directory."
layerValues buildahcli.LayerResults
budFlagsValues buildahcli.BudResults
fromAndBudValues buildahcli.FromAndBudResults
Expand Down Expand Up @@ -48,6 +47,7 @@ var (

func init() {
buildCommand.Command = _buildCommand
buildCommand.SetHelpTemplate(HelpTemplate())
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 @@ -40,6 +40,7 @@ var (

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

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

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

Expand Down
6 changes: 2 additions & 4 deletions cmd/podman/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ import (

var (
commitCommand cliconfig.CommitValues
commitDescription = `Create an image from a container's changes.
Optionally tag the image created, set the author with the --author flag,
set the commit message with the --message flag,
and make changes to the instructions with the --change flag.`
commitDescription = `Create an image from a container's changes. Optionally tag the image created, set the author with the --author flag, set the commit message with the --message flag, and make changes to the instructions with the --change flag.`

_commitCommand = &cobra.Command{
Use: "commit [flags] CONTAINER IMAGE",
Expand All @@ -41,6 +38,7 @@ var (

func init() {
commitCommand.Command = _commitCommand
commitCommand.SetHelpTemplate(HelpTemplate())
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, " | ")))
Expand Down
12 changes: 12 additions & 0 deletions cmd/podman/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,18 @@ func scrubServer(server string) string {
return strings.TrimPrefix(server, "http://")
}

// HelpTemplate returns the help template for podman commands
// This uses the short and long options.
// command should not use this.
func HelpTemplate() string {
return `{{.Short}}
Description:
{{.Long}}
{{if or .Runnable .HasSubCommands}}{{.UsageString}}{{end}}`
}

// UsageTemplate returns the usage template for podman commands
// This blocks the desplaying of the global options. The main podman
// command should not use this.
Expand Down
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.SetHelpTemplate(HelpTemplate())
pruneContainersCommand.SetUsageTemplate(UsageTemplate())
flags := pruneContainersCommand.Flags()
flags.BoolVarP(&pruneContainersCommand.Force, "force", "f", false, "Force removal of a running container. The default is false")
Expand Down
9 changes: 7 additions & 2 deletions cmd/podman/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ import (
var (
cpCommand cliconfig.CpValues

cpDescription = "Copy files/folders between a container and the local filesystem"
_cpCommand = &cobra.Command{
cpDescription = `Command copies the contents of SRC_PATH to the DEST_PATH.
You can copy from the container's file system to the local machine or the reverse, from the local filesystem to the container. If "-" is specified for either the SRC_PATH or DEST_PATH, you can also stream a tar archive from STDIN or to STDOUT. The CONTAINER can be a running or stopped container. The SRC_PATH or DEST_PATH can be a file or directory.
`
_cpCommand = &cobra.Command{
Use: "cp [flags] SRC_PATH DEST_PATH",
Short: "Copy files/folders between a container and the local filesystem",
Long: cpDescription,
Expand All @@ -45,6 +48,8 @@ func init() {
cpCommand.Command = _cpCommand
flags := cpCommand.Flags()
flags.BoolVar(&cpCommand.Extract, "extract", false, "Extract the tar file into the destination directory.")
cpCommand.SetHelpTemplate(HelpTemplate())
cpCommand.SetUsageTemplate(UsageTemplate())
rootCmd.AddCommand(cpCommand.Command)
}

Expand Down
9 changes: 4 additions & 5 deletions cmd/podman/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ import (

var (
createCommand cliconfig.CreateValues
createDescription = "Creates a new container from the given image or" +
" storage and prepares it for running the specified command. The" +
" container ID is then printed to stdout. You can then start it at" +
" any time with the podman start <container_id> command. The container" +
" will be created with the initial state 'created'."
createDescription = `Creates a new container from the given image or storage and prepares it for running the specified command.
The container ID is then printed to stdout. You can then start it at any time with the podman start <container_id> command. The container will be created with the initial state 'created'.`
_createCommand = &cobra.Command{
Use: "create [flags] IMAGE [COMMAND [ARG...]]",
Short: "Create but do not start a container",
Expand All @@ -64,6 +62,7 @@ var (

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

getCreateFlags(&createCommand.PodmanCommand)
Expand Down
4 changes: 2 additions & 2 deletions cmd/podman/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ func (so stdoutStruct) Out() error {

var (
diffCommand cliconfig.DiffValues
diffDescription = fmt.Sprint(`Displays changes on a container or image's filesystem. The
container or image will be compared to its parent layer`)
diffDescription = fmt.Sprint(`Displays changes on a container or image's filesystem. The container or image will be compared to its parent layer.`)

_diffCommand = &cobra.Command{
Use: "diff [flags] CONTAINER | IMAGE",
Expand All @@ -54,6 +53,7 @@ var (

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

Expand Down
6 changes: 2 additions & 4 deletions cmd/podman/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ import (
var (
execCommand cliconfig.ExecValues

execDescription = `
podman exec
Run a command in a running container
execDescription = `Execute the specified command inside a running container.
`
_execCommand = &cobra.Command{
Use: "exec [flags] CONTAINER [COMMAND [ARG...]]",
Expand All @@ -39,6 +36,7 @@ var (

func init() {
execCommand.Command = _execCommand
execCommand.SetHelpTemplate(HelpTemplate())
execCommand.SetUsageTemplate(UsageTemplate())
flags := execCommand.Flags()
flags.SetInterspersed(false)
Expand Down
18 changes: 6 additions & 12 deletions cmd/podman/exists.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,12 @@ var (
containerExistsCommand cliconfig.ContainerExistsValues
podExistsCommand cliconfig.PodExistsValues

imageExistsDescription = `
podman image exists
imageExistsDescription = `If the named image exists in local storage, podman image exists exits with 0, otherwise the exit code will be 1.`

Check if an image exists in local storage
`
containerExistsDescription = `
podman container exists
containerExistsDescription = `If the named container exists in local storage, podman container exists exits with 0, otherwise the exit code will be 1.`

Check if a container exists in local storage
`
podExistsDescription = `
podman pod exists
podExistsDescription = `If the named pod exists in local storage, podman pod exists exits with 0, otherwise the exit code will be 1.`

Check if a pod exists in local storage
`
_imageExistsCommand = &cobra.Command{
Use: "exists IMAGE",
Short: "Check if an image exists in local storage",
Expand Down Expand Up @@ -75,12 +66,15 @@ var (
func init() {
imageExistsCommand.Command = _imageExistsCommand
imageExistsCommand.DisableFlagsInUseLine = true
imageExistsCommand.SetHelpTemplate(HelpTemplate())
imageExistsCommand.SetUsageTemplate(UsageTemplate())
containerExistsCommand.Command = _containerExistsCommand
containerExistsCommand.DisableFlagsInUseLine = true
containerExistsCommand.SetHelpTemplate(HelpTemplate())
containerExistsCommand.SetUsageTemplate(UsageTemplate())
podExistsCommand.Command = _podExistsCommand
podExistsCommand.DisableFlagsInUseLine = true
podExistsCommand.SetHelpTemplate(HelpTemplate())
podExistsCommand.SetUsageTemplate(UsageTemplate())
}

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

func init() {
exportCommand.Command = _exportCommand
exportCommand.SetHelpTemplate(HelpTemplate())
exportCommand.SetUsageTemplate(UsageTemplate())
flags := exportCommand.Flags()
flags.StringVarP(&exportCommand.Output, "output", "o", "/dev/stdout", "Write to a file, default is STDOUT")
Expand Down
9 changes: 6 additions & 3 deletions cmd/podman/generate_kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ import (

var (
containerKubeCommand cliconfig.GenerateKubeValues
containerKubeDescription = "Generate Kubernetes Pod YAML"
_containerKubeCommand = &cobra.Command{
containerKubeDescription = `Command generates Kubernetes Pod YAML (v1 specification) from a podman container or pod.
Whether the input is for a container or pod, Podman will always generate the specification as a Pod. The input may be in the form of a pod or container name or ID.`
_containerKubeCommand = &cobra.Command{
Use: "kube [flags] CONTAINER | POD",
Short: "Generate Kubernetes pod YAML for a container or pod",
Short: "Generate Kubernetes pod YAML from a container or pod",
Long: containerKubeDescription,
RunE: func(cmd *cobra.Command, args []string) error {
containerKubeCommand.InputArgs = args
Expand All @@ -33,6 +35,7 @@ var (

func init() {
containerKubeCommand.Command = _containerKubeCommand
containerKubeCommand.SetHelpTemplate(HelpTemplate())
containerKubeCommand.SetUsageTemplate(UsageTemplate())
flags := containerKubeCommand.Flags()
flags.BoolVarP(&containerKubeCommand.Service, "service", "s", false, "Generate YAML for kubernetes service object")
Expand Down
6 changes: 4 additions & 2 deletions cmd/podman/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ type historyOptions struct {
var (
historyCommand cliconfig.HistoryValues

historyDescription = "Displays the history of an image. The information can be printed out in an easy to read, " +
"or user specified format, and can be truncated."
historyDescription = `Displays the history of an image.
The information can be printed out in an easy to read, or user specified format, and can be truncated.`
_historyCommand = &cobra.Command{
Use: "history [flags] IMAGE",
Short: "Show history of a specified image",
Expand All @@ -53,6 +54,7 @@ var (

func init() {
historyCommand.Command = _historyCommand
historyCommand.SetHelpTemplate(HelpTemplate())
historyCommand.SetUsageTemplate(UsageTemplate())
flags := historyCommand.Flags()
flags.StringVar(&historyCommand.Format, "format", "", "Change the output to JSON or a Go template")
Expand Down
3 changes: 2 additions & 1 deletion cmd/podman/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (a imagesSortedSize) Less(i, j int) bool {

var (
imagesCommand cliconfig.ImagesValues
imagesDescription = "lists locally stored images."
imagesDescription = "Lists images previously pulled to the system or created on the system."

_imagesCommand = cobra.Command{
Use: "images [flags] [IMAGE]",
Expand All @@ -103,6 +103,7 @@ var (
)

func imagesInit(command *cliconfig.ImagesValues) {
command.SetHelpTemplate(HelpTemplate())
command.SetUsageTemplate(UsageTemplate())

flags := command.Flags()
Expand Down
7 changes: 3 additions & 4 deletions cmd/podman/images_prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ import (

var (
pruneImagesCommand cliconfig.PruneImagesValues
pruneImagesDescription = `
podman image prune
pruneImagesDescription = `Removes all unnamed images from local storage.
Removes all unnamed images from local storage
`
If an image is not being used by a container, it will be removed from the system.`
_pruneImagesCommand = &cobra.Command{
Use: "prune",
Args: noSubArgs,
Expand All @@ -31,6 +29,7 @@ var (

func init() {
pruneImagesCommand.Command = _pruneImagesCommand
pruneImagesCommand.SetHelpTemplate(HelpTemplate())
pruneImagesCommand.SetUsageTemplate(UsageTemplate())
flags := pruneImagesCommand.Flags()
flags.BoolVarP(&pruneImagesCommand.All, "all", "a", false, "Remove all unused images, not just dangling ones")
Expand Down
7 changes: 4 additions & 3 deletions cmd/podman/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ var (
importCommand cliconfig.ImportValues

importDescription = `Create a container image from the contents of the specified tarball (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz).
Note remote tar balls can be specified, via web address.
Optionally tag the image. You can specify the instructions using the --change option.
`
Note remote tar balls can be specified, via web address.
Optionally tag the image. You can specify the instructions using the --change option.`
_importCommand = &cobra.Command{
Use: "import [flags] PATH [REFERENCE]",
Short: "Import a tarball to create a filesystem image",
Expand All @@ -33,6 +33,7 @@ var (

func init() {
importCommand.Command = _importCommand
importCommand.SetHelpTemplate(HelpTemplate())
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")
Expand Down
10 changes: 7 additions & 3 deletions cmd/podman/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ import (
var (
infoCommand cliconfig.InfoValues

infoDescription = "Display podman system information"
_infoCommand = &cobra.Command{
infoDescription = `Display information pertaining to the host, current storage stats, and build of podman.
Useful for the user and when reporting issues.
`
_infoCommand = &cobra.Command{
Use: "info",
Args: noSubArgs,
Long: infoDescription,
Short: `Display information pertaining to the host, current storage stats, and build of podman. Useful for the user and when reporting issues.`,
Short: "Display podman system information",
RunE: func(cmd *cobra.Command, args []string) error {
infoCommand.InputArgs = args
infoCommand.GlobalFlags = MainGlobalOpts
Expand All @@ -33,6 +36,7 @@ var (

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

Expand Down
7 changes: 5 additions & 2 deletions cmd/podman/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ const (
var (
inspectCommand cliconfig.InspectValues

inspectDescription = "This displays the low-level information on containers and images identified by name or ID. By default, this will render all results in a JSON array. If the container and image have the same name, this will return container JSON for unspecified type."
_inspectCommand = &cobra.Command{
inspectDescription = `This displays the low-level information on containers and images identified by name or ID.
If given a name that matches both a container and an image, this command inspects the container. By default, this will render all results in a JSON array.`
_inspectCommand = &cobra.Command{
Use: "inspect [flags] CONTAINER | IMAGE",
Short: "Display the configuration of a container or image",
Long: inspectDescription,
Expand All @@ -42,6 +44,7 @@ var (

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

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

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

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

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

Expand Down
Loading

0 comments on commit 94e89fc

Please sign in to comment.