mirror of https://github.com/docker/docs.git
Add argument assertion to inspect/status/url commands
Signed-off-by: Kazuyuki Suzuki <kechol28@gmail.com>
This commit is contained in:
parent
1588f2217a
commit
2bc53a6ac3
|
@ -23,6 +23,11 @@ var funcMap = template.FuncMap{
|
||||||
}
|
}
|
||||||
|
|
||||||
func cmdInspect(c *cli.Context) {
|
func cmdInspect(c *cli.Context) {
|
||||||
|
if len(c.Args()) == 0 {
|
||||||
|
cli.ShowCommandHelp(c, "inspect")
|
||||||
|
log.Fatal("You must specify a machine name")
|
||||||
|
}
|
||||||
|
|
||||||
tmplString := c.String("format")
|
tmplString := c.String("format")
|
||||||
if tmplString != "" {
|
if tmplString != "" {
|
||||||
var tmpl *template.Template
|
var tmpl *template.Template
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/docker/machine/libmachine/log"
|
|
||||||
|
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
|
"github.com/docker/machine/libmachine/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func cmdStatus(c *cli.Context) {
|
func cmdStatus(c *cli.Context) {
|
||||||
|
if len(c.Args()) != 1 {
|
||||||
|
log.Fatal(ErrExpectedOneMachine)
|
||||||
|
}
|
||||||
host := getFirstArgHost(c)
|
host := getFirstArgHost(c)
|
||||||
currentState, err := host.Driver.GetState()
|
currentState, err := host.Driver.GetState()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -3,12 +3,14 @@ package commands
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/docker/machine/libmachine/log"
|
|
||||||
|
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
|
"github.com/docker/machine/libmachine/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func cmdUrl(c *cli.Context) {
|
func cmdUrl(c *cli.Context) {
|
||||||
|
if len(c.Args()) != 1 {
|
||||||
|
log.Fatal(ErrExpectedOneMachine)
|
||||||
|
}
|
||||||
url, err := getFirstArgHost(c).GetURL()
|
url, err := getFirstArgHost(c).GetURL()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load ${BASE_TEST_DIR}/helpers.bash
|
||||||
|
|
||||||
|
@test "inspect: show error in case of no args" {
|
||||||
|
run machine inspect
|
||||||
|
[ "$status" -eq 1 ]
|
||||||
|
[[ ${output} == *"must specify a machine name"* ]]
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load ${BASE_TEST_DIR}/helpers.bash
|
||||||
|
|
||||||
|
@test "status: show error in case of no args" {
|
||||||
|
run machine inspect
|
||||||
|
[ "$status" -eq 1 ]
|
||||||
|
[[ ${output} == *"must specify a machine name"* ]]
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load ${BASE_TEST_DIR}/helpers.bash
|
||||||
|
|
||||||
|
@test "url: show error in case of no args" {
|
||||||
|
run machine inspect
|
||||||
|
[ "$status" -eq 1 ]
|
||||||
|
[[ ${output} == *"must specify a machine name"* ]]
|
||||||
|
}
|
Loading…
Reference in New Issue