mirror of
https://github.com/containers/podman
synced 2024-10-20 17:23:30 +00:00
Short options!
Any subcommand that has two or more booleon short options can now combine those two options. For example: kpod rmi -af (Remove all images forceably) Signed-off-by: baude <bbaude@redhat.com> Closes: #100 Approved by: rhatdan
This commit is contained in:
parent
265efcb9f8
commit
3db735c6d1
|
@ -131,13 +131,14 @@ var createDescription = "Creates a new container from the given image or" +
|
|||
" will be created with the initial state 'created'."
|
||||
|
||||
var createCommand = cli.Command{
|
||||
Name: "create",
|
||||
Usage: "create but do not start a container",
|
||||
Description: createDescription,
|
||||
Flags: createFlags,
|
||||
Action: createCmd,
|
||||
ArgsUsage: "IMAGE [COMMAND [ARG...]]",
|
||||
SkipArgReorder: true,
|
||||
Name: "create",
|
||||
Usage: "create but do not start a container",
|
||||
Description: createDescription,
|
||||
Flags: createFlags,
|
||||
Action: createCmd,
|
||||
ArgsUsage: "IMAGE [COMMAND [ARG...]]",
|
||||
SkipArgReorder: true,
|
||||
UseShortOptionHandling: true,
|
||||
}
|
||||
|
||||
func createCmd(c *cli.Context) error {
|
||||
|
|
|
@ -71,12 +71,13 @@ var (
|
|||
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 = cli.Command{
|
||||
Name: "history",
|
||||
Usage: "Show history of a specified image",
|
||||
Description: historyDescription,
|
||||
Flags: historyFlags,
|
||||
Action: historyCmd,
|
||||
ArgsUsage: "",
|
||||
Name: "history",
|
||||
Usage: "Show history of a specified image",
|
||||
Description: historyDescription,
|
||||
Flags: historyFlags,
|
||||
Action: historyCmd,
|
||||
ArgsUsage: "",
|
||||
UseShortOptionHandling: true,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -72,12 +72,13 @@ var (
|
|||
|
||||
imagesDescription = "lists locally stored images."
|
||||
imagesCommand = cli.Command{
|
||||
Name: "images",
|
||||
Usage: "list images in local storage",
|
||||
Description: imagesDescription,
|
||||
Flags: imagesFlags,
|
||||
Action: imagesCmd,
|
||||
ArgsUsage: "",
|
||||
Name: "images",
|
||||
Usage: "list images in local storage",
|
||||
Description: imagesDescription,
|
||||
Flags: imagesFlags,
|
||||
Action: imagesCmd,
|
||||
ArgsUsage: "",
|
||||
UseShortOptionHandling: true,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -133,12 +133,13 @@ var (
|
|||
}
|
||||
psDescription = "Prints out information about the containers"
|
||||
psCommand = cli.Command{
|
||||
Name: "ps",
|
||||
Usage: "List containers",
|
||||
Description: psDescription,
|
||||
Flags: psFlags,
|
||||
Action: psCmd,
|
||||
ArgsUsage: "",
|
||||
Name: "ps",
|
||||
Usage: "List containers",
|
||||
Description: psDescription,
|
||||
Flags: psFlags,
|
||||
Action: psCmd,
|
||||
ArgsUsage: "",
|
||||
UseShortOptionHandling: true,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -25,10 +25,11 @@ var (
|
|||
Name: "rm",
|
||||
Usage: fmt.Sprintf(`kpod rm will remove one or more containers from the host. The container name or ID can be used.
|
||||
This does not remove images. Running containers will not be removed without the -f option.`),
|
||||
Description: rmDescription,
|
||||
Flags: rmFlags,
|
||||
Action: rmCmd,
|
||||
ArgsUsage: "",
|
||||
Description: rmDescription,
|
||||
Flags: rmFlags,
|
||||
Action: rmCmd,
|
||||
ArgsUsage: "",
|
||||
UseShortOptionHandling: true,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ var (
|
|||
Action: rmiCmd,
|
||||
ArgsUsage: "IMAGE-NAME-OR-ID [...]",
|
||||
Flags: rmiFlags,
|
||||
UseShortOptionHandling: true,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -13,13 +13,14 @@ import (
|
|||
var runDescription = "Runs a command in a new container from the given image"
|
||||
|
||||
var runCommand = cli.Command{
|
||||
Name: "run",
|
||||
Usage: "run a command in a new container",
|
||||
Description: runDescription,
|
||||
Flags: createFlags,
|
||||
Action: runCmd,
|
||||
ArgsUsage: "IMAGE [COMMAND [ARG...]]",
|
||||
SkipArgReorder: true,
|
||||
Name: "run",
|
||||
Usage: "run a command in a new container",
|
||||
Description: runDescription,
|
||||
Flags: createFlags,
|
||||
Action: runCmd,
|
||||
ArgsUsage: "IMAGE [COMMAND [ARG...]]",
|
||||
SkipArgReorder: true,
|
||||
UseShortOptionHandling: true,
|
||||
}
|
||||
|
||||
func runCmd(c *cli.Context) error {
|
||||
|
|
|
@ -34,12 +34,13 @@ var (
|
|||
`
|
||||
|
||||
startCommand = cli.Command{
|
||||
Name: "start",
|
||||
Usage: "Start one or more containers",
|
||||
Description: startDescription,
|
||||
Flags: startFlags,
|
||||
Action: startCmd,
|
||||
ArgsUsage: "CONTAINER-NAME [CONTAINER-NAME ...]",
|
||||
Name: "start",
|
||||
Usage: "Start one or more containers",
|
||||
Description: startDescription,
|
||||
Flags: startFlags,
|
||||
Action: startCmd,
|
||||
ArgsUsage: "CONTAINER-NAME [CONTAINER-NAME ...]",
|
||||
UseShortOptionHandling: true,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -21,3 +21,9 @@ function teardown() {
|
|||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "ensure short options" {
|
||||
run ${KPOD_BINARY} ${KPOD_OPTIONS} create -dt ${BB_GLIBC} ls
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
|
|
@ -45,3 +45,9 @@ function setup() {
|
|||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "kpod history short options" {
|
||||
run ${KPOD_BINARY} ${KPOD_OPTIONS} history -qH $ALPINE
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
|
|
@ -40,3 +40,9 @@ function teardown() {
|
|||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "kpod images short options" {
|
||||
run ${KPOD_BINARY} ${KPOD_OPTIONS} images -qn
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
|
|
@ -120,3 +120,12 @@ function teardown() {
|
|||
[ "$status" -eq 0 ]
|
||||
run ${KPOD_BINARY} ${KPOD_OPTIONS} stop $ctr_id
|
||||
}
|
||||
|
||||
@test "kpod ps short options" {
|
||||
run ${KPOD_BINARY} ${KPOD_OPTIONS} run -d ${ALPINE} sleep 99
|
||||
ctr_id="$output"
|
||||
run bash -c ${KPOD_BINARY} ${KPOD_OPTIONS} ps -aqs
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
run ${KPOD_BINARY} ${KPOD_OPTIONS} stop $ctr_id
|
||||
}
|
||||
|
|
|
@ -60,12 +60,12 @@ function teardown() {
|
|||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "remove all containers with one running" {
|
||||
@test "remove all containers with one running with short options" {
|
||||
${KPOD_BINARY} ${KPOD_OPTIONS} create $BB ls
|
||||
${KPOD_BINARY} ${KPOD_OPTIONS} create $BB ls -l
|
||||
${KPOD_BINARY} ${KPOD_OPTIONS} create $BB whoami
|
||||
${KPOD_BINARY} ${KPOD_OPTIONS} run -d ${ALPINE} sleep 30
|
||||
run ${KPOD_BINARY} $KPOD_OPTIONS rm -a -f
|
||||
run ${KPOD_BINARY} $KPOD_OPTIONS rm -af
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
|
|
@ -43,10 +43,10 @@ function pullImages() {
|
|||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "kpod rmi all images forceably" {
|
||||
@test "kpod rmi all images forceably with short options" {
|
||||
pullImages
|
||||
${KPOD_BINARY} $KPOD_OPTIONS create ${IMAGE1} ls
|
||||
run ${KPOD_BINARY} $KPOD_OPTIONS rmi -a -f
|
||||
run ${KPOD_BINARY} $KPOD_OPTIONS rmi -af
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
|
|
@ -16,6 +16,12 @@ function setup() {
|
|||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "run a container based on local image with short options" {
|
||||
run bash -c "${KPOD_BINARY} ${KPOD_OPTIONS} run -dt $BB ls"
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "run a container based on a remote image" {
|
||||
run bash -c "${KPOD_BINARY} ${KPOD_OPTIONS} run ${BB_GLIBC} ls"
|
||||
echo "$output"
|
||||
|
@ -65,25 +71,22 @@ function setup() {
|
|||
}
|
||||
|
||||
@test "run environment test" {
|
||||
|
||||
${KPOD_BINARY} ${KPOD_OPTIONS} pull ${ALPINE}
|
||||
|
||||
run bash -c "${KPOD_BINARY} ${KPOD_OPTIONS} run -env FOO=BAR ${ALPINE} printenv FOO | tr -d '\r'"
|
||||
run bash -c "${KPOD_BINARY} ${KPOD_OPTIONS} run --env FOO=BAR ${ALPINE} printenv FOO | tr -d '\r'"
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
[ $output = "BAR" ]
|
||||
|
||||
run bash -c "${KPOD_BINARY} ${KPOD_OPTIONS} run -env PATH="/bin" ${ALPINE} printenv PATH | tr -d '\r'"
|
||||
run bash -c "${KPOD_BINARY} ${KPOD_OPTIONS} run --env PATH="/bin" ${ALPINE} printenv PATH | tr -d '\r'"
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
[ $output = "/bin" ]
|
||||
|
||||
run bash -c "export FOO=BAR; ${KPOD_BINARY} ${KPOD_OPTIONS} run -env FOO ${ALPINE} printenv FOO | tr -d '\r'"
|
||||
run bash -c "export FOO=BAR; ${KPOD_BINARY} ${KPOD_OPTIONS} run --env FOO ${ALPINE} printenv FOO | tr -d '\r'"
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$output" = "BAR" ]
|
||||
|
||||
run bash -c "${KPOD_BINARY} ${KPOD_OPTIONS} run -env FOO ${ALPINE} printenv"
|
||||
run bash -c "${KPOD_BINARY} ${KPOD_OPTIONS} run --env FOO ${ALPINE} printenv"
|
||||
echo "$output"
|
||||
[ "$status" -ne 0 ]
|
||||
|
||||
|
|
Loading…
Reference in a new issue