diff --git a/cmd/kpod/create.go b/cmd/kpod/create.go index 9e810af6ee..1b340f96db 100644 --- a/cmd/kpod/create.go +++ b/cmd/kpod/create.go @@ -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 { diff --git a/cmd/kpod/history.go b/cmd/kpod/history.go index eba5b8b352..211a843d06 100644 --- a/cmd/kpod/history.go +++ b/cmd/kpod/history.go @@ -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, } ) diff --git a/cmd/kpod/images.go b/cmd/kpod/images.go index 71bc877c92..7b020c984d 100644 --- a/cmd/kpod/images.go +++ b/cmd/kpod/images.go @@ -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, } ) diff --git a/cmd/kpod/ps.go b/cmd/kpod/ps.go index 13d72429e9..2748bea5a8 100644 --- a/cmd/kpod/ps.go +++ b/cmd/kpod/ps.go @@ -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, } ) diff --git a/cmd/kpod/rm.go b/cmd/kpod/rm.go index 511679770b..2f767457fb 100644 --- a/cmd/kpod/rm.go +++ b/cmd/kpod/rm.go @@ -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, } ) diff --git a/cmd/kpod/rmi.go b/cmd/kpod/rmi.go index b69b3b5140..1b4cb7390c 100644 --- a/cmd/kpod/rmi.go +++ b/cmd/kpod/rmi.go @@ -27,6 +27,7 @@ var ( Action: rmiCmd, ArgsUsage: "IMAGE-NAME-OR-ID [...]", Flags: rmiFlags, + UseShortOptionHandling: true, } ) diff --git a/cmd/kpod/run.go b/cmd/kpod/run.go index eb3dee88c8..934096c210 100644 --- a/cmd/kpod/run.go +++ b/cmd/kpod/run.go @@ -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 { diff --git a/cmd/kpod/start.go b/cmd/kpod/start.go index fcc4c97364..c874c541ca 100644 --- a/cmd/kpod/start.go +++ b/cmd/kpod/start.go @@ -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, } ) diff --git a/test/kpod_create.bats b/test/kpod_create.bats index 3d3efcff36..e1a1873320 100644 --- a/test/kpod_create.bats +++ b/test/kpod_create.bats @@ -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 ] +} diff --git a/test/kpod_history.bats b/test/kpod_history.bats index 9ce2be079b..5e99696b23 100644 --- a/test/kpod_history.bats +++ b/test/kpod_history.bats @@ -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 ] +} diff --git a/test/kpod_images.bats b/test/kpod_images.bats index 6f0c53670b..9812a33c52 100644 --- a/test/kpod_images.bats +++ b/test/kpod_images.bats @@ -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 ] +} diff --git a/test/kpod_ps.bats b/test/kpod_ps.bats index 859cbaa99e..3a5d94f594 100644 --- a/test/kpod_ps.bats +++ b/test/kpod_ps.bats @@ -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 +} diff --git a/test/kpod_rm.bats b/test/kpod_rm.bats index e9843659a1..3a7821b564 100644 --- a/test/kpod_rm.bats +++ b/test/kpod_rm.bats @@ -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 ] } diff --git a/test/kpod_rmi.bats b/test/kpod_rmi.bats index 77990d5001..034fd9ab7e 100644 --- a/test/kpod_rmi.bats +++ b/test/kpod_rmi.bats @@ -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 ] } diff --git a/test/kpod_run.bats b/test/kpod_run.bats index 5f5377a5e4..09a66b874c 100644 --- a/test/kpod_run.bats +++ b/test/kpod_run.bats @@ -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 ]