From a7a691809a3125cce691c7934a98a2511b9cb6db Mon Sep 17 00:00:00 2001 From: TomSweeneyRedHat Date: Wed, 13 Feb 2019 19:22:29 -0500 Subject: Add examples for Cobra Signed-off-by: TomSweeneyRedHat First pass of entries for the Examples listed in the Cobra Help. Will add others in following PR's. --- cmd/podman/commit.go | 4 +++- cmd/podman/common.go | 2 +- cmd/podman/create.go | 4 +++- cmd/podman/exists.go | 6 +++--- cmd/podman/info.go | 2 +- cmd/podman/inspect.go | 4 +++- cmd/podman/login.go | 4 +++- cmd/podman/pod_inspect.go | 2 +- cmd/podman/pod_rm.go | 4 +++- 9 files changed, 21 insertions(+), 11 deletions(-) (limited to 'cmd/podman') diff --git a/cmd/podman/commit.go b/cmd/podman/commit.go index dc53e68d1..d8ced0e36 100644 --- a/cmd/podman/commit.go +++ b/cmd/podman/commit.go @@ -33,7 +33,9 @@ var ( commitCommand.GlobalFlags = MainGlobalOpts return commitCmd(&commitCommand) }, - Example: "CONTAINER [REPOSITORY[:TAG]]", + Example: `podman commit -q --message "committing container to image" reverent_golick image-commited + podman commit -q --author "firstName lastName" reverent_golick image-commited + podman commit -q --pause=false containerID image-commited`, } ) diff --git a/cmd/podman/common.go b/cmd/podman/common.go index 417e938b7..ec755c4a8 100644 --- a/cmd/podman/common.go +++ b/cmd/podman/common.go @@ -514,7 +514,7 @@ Aliases: {{.NameAndAliases}}{{end}}{{if .HasExample}} Examples: -{{.Example}}{{end}}{{if .HasAvailableSubCommands}} + {{.Example}}{{end}}{{if .HasAvailableSubCommands}} Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "help"))}} {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}} diff --git a/cmd/podman/create.go b/cmd/podman/create.go index 1a7f419c0..f514afe30 100644 --- a/cmd/podman/create.go +++ b/cmd/podman/create.go @@ -49,7 +49,9 @@ var ( createCommand.GlobalFlags = MainGlobalOpts return createCmd(&createCommand) }, - Example: "IMAGE [COMMAND [ARG...]]", + Example: `podman create alpine ls + podman create --annotation HELLO=WORLD alpine ls + podman create -t -i --name myctr alpine ls`, } defaultEnvVariables = map[string]string{ diff --git a/cmd/podman/exists.go b/cmd/podman/exists.go index 15ddaec06..7645bb716 100644 --- a/cmd/podman/exists.go +++ b/cmd/podman/exists.go @@ -41,7 +41,7 @@ var ( imageExistsCommand.GlobalFlags = MainGlobalOpts return imageExistsCmd(&imageExistsCommand) }, - Example: "IMAGE-NAME", + Example: `podman image exists imageID`, } _containerExistsCommand = &cobra.Command{ @@ -54,7 +54,7 @@ var ( return containerExistsCmd(&containerExistsCommand) }, - Example: "CONTAINER-NAME", + Example: `podman container exists containerID`, } _podExistsCommand = &cobra.Command{ @@ -66,7 +66,7 @@ var ( podExistsCommand.GlobalFlags = MainGlobalOpts return podExistsCmd(&podExistsCommand) }, - Example: "POD-NAME", + Example: `podman pod exists podID`, } ) diff --git a/cmd/podman/info.go b/cmd/podman/info.go index d60b8f84f..06dbbd748 100644 --- a/cmd/podman/info.go +++ b/cmd/podman/info.go @@ -26,7 +26,7 @@ var ( infoCommand.GlobalFlags = MainGlobalOpts return infoCmd(&infoCommand) }, - Example: "", + Example: `podman info`, } ) diff --git a/cmd/podman/inspect.go b/cmd/podman/inspect.go index a29eb790e..a1f3ef81f 100644 --- a/cmd/podman/inspect.go +++ b/cmd/podman/inspect.go @@ -34,7 +34,9 @@ var ( inspectCommand.GlobalFlags = MainGlobalOpts return inspectCmd(&inspectCommand) }, - Example: "CONTAINER-OR-IMAGE [CONTAINER-OR-IMAGE]...", + Example: `podman inspect alpine + podman inspect --format "imageId: {{.Id}} size: {{.Size}}" alpine + podman inspect --format "image: {{.ImageName}} driver: {{.Driver}}" myctr`, } ) diff --git a/cmd/podman/login.go b/cmd/podman/login.go index 0bd58ff78..5c47b8c65 100644 --- a/cmd/podman/login.go +++ b/cmd/podman/login.go @@ -29,7 +29,9 @@ var ( loginCommand.GlobalFlags = MainGlobalOpts return loginCmd(&loginCommand) }, - Example: "REGISTRY", + Example: `podman login -u testuser -p testpassword localhost:5000 + podman login --authfile authdir/myauths.json quay.io + podman login -u testuser -p testpassword localhost:5000`, } ) diff --git a/cmd/podman/pod_inspect.go b/cmd/podman/pod_inspect.go index a0b691642..58b15328e 100644 --- a/cmd/podman/pod_inspect.go +++ b/cmd/podman/pod_inspect.go @@ -23,7 +23,7 @@ var ( podInspectCommand.GlobalFlags = MainGlobalOpts return podInspectCmd(&podInspectCommand) }, - Example: "[POD_NAME_OR_ID]", + Example: `podman pod inspect podID`, } ) diff --git a/cmd/podman/pod_rm.go b/cmd/podman/pod_rm.go index 389f44a20..54cee2a50 100644 --- a/cmd/podman/pod_rm.go +++ b/cmd/podman/pod_rm.go @@ -26,7 +26,9 @@ If --force is specified, all containers will be stopped, then removed. podRmCommand.GlobalFlags = MainGlobalOpts return podRmCmd(&podRmCommand) }, - Example: "[POD ...]", + Example: `podman pod rm mywebserverpod + podman pod rm -f 860a4b23 + podman pod rm -f -a`, } ) -- cgit v1.2.3-54-g00ecf