From 6751b2c3504096286977490d2eb70047f054e207 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Thu, 30 Aug 2018 08:35:47 +0200 Subject: run/create: reserve `-h` flag for hostname Move the `-h` short flag from `--help` to `--hostname` for podman-run, podman-create and podman-pod-create to be compatible with Docker. Fixes: #1367 Signed-off-by: Valentin Rothberg Closes: #1373 Approved by: rhatdan --- cmd/podman/common.go | 6 +++++- cmd/podman/create.go | 7 +++++++ cmd/podman/pod_create.go | 7 +++++++ cmd/podman/run.go | 8 ++++++++ cmd/podman/run_test.go | 7 ++++--- 5 files changed, 31 insertions(+), 4 deletions(-) (limited to 'cmd/podman') diff --git a/cmd/podman/common.go b/cmd/podman/common.go index 797e74c98..4ddfd5e0a 100644 --- a/cmd/podman/common.go +++ b/cmd/podman/common.go @@ -216,8 +216,12 @@ var createFlags = []cli.Flag{ Name: "group-add", Usage: "Add additional groups to join (default [])", }, + cli.BoolFlag{ + Name: "help", + Hidden: true, + }, cli.StringFlag{ - Name: "hostname", + Name: "hostname, h", Usage: "Set container hostname", }, cli.StringFlag{ diff --git a/cmd/podman/create.go b/cmd/podman/create.go index 78b206543..6b5151c1b 100644 --- a/cmd/podman/create.go +++ b/cmd/podman/create.go @@ -49,6 +49,7 @@ var createCommand = cli.Command{ Flags: createFlags, Action: createCmd, ArgsUsage: "IMAGE [COMMAND [ARG...]]", + HideHelp: true, SkipArgReorder: true, UseShortOptionHandling: true, } @@ -57,6 +58,12 @@ func createCmd(c *cli.Context) error { // TODO should allow user to create based off a directory on the host not just image // Need CLI support for this + // Docker-compatibility: the "-h" flag for run/create is reserved for + // the hostname (see https://github.com/containers/libpod/issues/1367). + if c.Bool("help") { + cli.ShowCommandHelpAndExit(c, "run", 0) + } + if err := validateFlags(c, createFlags); err != nil { return err } diff --git a/cmd/podman/pod_create.go b/cmd/podman/pod_create.go index 4eb3126e3..3e712619e 100644 --- a/cmd/podman/pod_create.go +++ b/cmd/podman/pod_create.go @@ -71,6 +71,7 @@ var podCreateCommand = cli.Command{ Description: podCreateDescription, Flags: podCreateFlags, Action: podCreateCmd, + HideHelp: true, SkipArgReorder: true, UseShortOptionHandling: true, } @@ -79,6 +80,12 @@ func podCreateCmd(c *cli.Context) error { var options []libpod.PodCreateOption var err error + // Docker-compatibility: the "-h" flag for run/create is reserved for + // the hostname (see https://github.com/containers/libpod/issues/1367). + if c.Bool("help") { + cli.ShowCommandHelpAndExit(c, "run", 0) + } + if err = validateFlags(c, createFlags); err != nil { return err } diff --git a/cmd/podman/run.go b/cmd/podman/run.go index 997068a55..a6d0526ff 100644 --- a/cmd/podman/run.go +++ b/cmd/podman/run.go @@ -34,12 +34,20 @@ var runCommand = cli.Command{ Flags: runFlags, Action: runCmd, ArgsUsage: "IMAGE [COMMAND [ARG...]]", + HideHelp: true, SkipArgReorder: true, UseShortOptionHandling: true, } func runCmd(c *cli.Context) error { var imageName string + + // Docker-compatibility: the "-h" flag for run/create is reserved for + // the hostname (see https://github.com/containers/libpod/issues/1367). + if c.Bool("help") { + cli.ShowCommandHelpAndExit(c, "run", 0) + } + if err := validateFlags(c, createFlags); err != nil { return err } diff --git a/cmd/podman/run_test.go b/cmd/podman/run_test.go index 397b3bb71..0a79f6ec3 100644 --- a/cmd/podman/run_test.go +++ b/cmd/podman/run_test.go @@ -17,9 +17,10 @@ var ( cmd = []string{"podman", "test", "alpine"} CLI *cli.Context testCommand = cli.Command{ - Name: "test", - Flags: createFlags, - Action: testCmd, + Name: "test", + Flags: createFlags, + Action: testCmd, + HideHelp: true, } ) -- cgit v1.2.3-54-g00ecf