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 <vrothberg@suse.com>

Closes: #1373
Approved by: rhatdan
This commit is contained in:
Valentin Rothberg 2018-08-30 08:35:47 +02:00 committed by Atomic Bot
parent 65c31d49f9
commit 6751b2c350
5 changed files with 31 additions and 4 deletions

View File

@ -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{

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -20,6 +20,7 @@ var (
Name: "test",
Flags: createFlags,
Action: testCmd,
HideHelp: true,
}
)