diff --git a/fleetctl/destroy.go b/fleetctl/destroy.go index d00778aa1..86b8d5f01 100644 --- a/fleetctl/destroy.go +++ b/fleetctl/destroy.go @@ -29,6 +29,10 @@ Destroyed units are impossible to start unless re-submitted.`, } func runDestroyUnits(args []string) (exit int) { + if len(args) == 0 { + stderr("One unit file must be provided.") + return 1 + } for _, v := range args { name := unitNameMangle(v) err := cAPI.DestroyUnit(name) diff --git a/fleetctl/load.go b/fleetctl/load.go index 497f86058..fb801ea77 100644 --- a/fleetctl/load.go +++ b/fleetctl/load.go @@ -46,6 +46,10 @@ func init() { } func runLoadUnits(args []string) (exit int) { + if len(args) == 0 { + stderr("One unit file must be provided.") + return 1 + } if err := lazyCreateUnits(args); err != nil { stderr("Error creating units: %v", err) return 1 diff --git a/fleetctl/start.go b/fleetctl/start.go index 77ea0d343..203dd9a8a 100644 --- a/fleetctl/start.go +++ b/fleetctl/start.go @@ -54,6 +54,10 @@ func init() { } func runStartUnit(args []string) (exit int) { + if len(args) == 0 { + stderr("One unit file must be provided.") + return 1 + } if err := lazyCreateUnits(args); err != nil { stderr("Error creating units: %v", err) return 1 diff --git a/fleetctl/status.go b/fleetctl/status.go index c1b065f1b..aa89625ee 100644 --- a/fleetctl/status.go +++ b/fleetctl/status.go @@ -44,6 +44,10 @@ func init() { } func runStatusUnits(args []string) (exit int) { + if len(args) == 0 { + stderr("One unit file must be provided.") + return 1 + } units, err := cAPI.Units() if err != nil { stderr("Error retrieving unit: %v", err) diff --git a/fleetctl/stop.go b/fleetctl/stop.go index 262946bfb..94b85668d 100644 --- a/fleetctl/stop.go +++ b/fleetctl/stop.go @@ -52,12 +52,22 @@ func init() { } func runStopUnit(args []string) (exit int) { + if len(args) == 0 { + stderr("One unit file must be provided.") + return 1 + } + units, err := findUnits(args) if err != nil { stderr("%v", err) return 1 } + if len(units) == 0 { + stderr("The units to be stopped are not found in registry.") + return 1 + } + stopping := make([]string, 0) for _, u := range units { if !suToGlobal(u) { diff --git a/fleetctl/submit.go b/fleetctl/submit.go index cbfe03f93..767078817 100644 --- a/fleetctl/submit.go +++ b/fleetctl/submit.go @@ -36,6 +36,10 @@ func init() { } func runSubmitUnits(args []string) (exit int) { + if len(args) == 0 { + stderr("One unit file must be provided.") + return 1 + } if err := lazyCreateUnits(args); err != nil { stderr("Error creating units: %v", err) exit = 1 diff --git a/fleetctl/unload.go b/fleetctl/unload.go index 6758f2825..d2d0245e9 100644 --- a/fleetctl/unload.go +++ b/fleetctl/unload.go @@ -36,6 +36,10 @@ func init() { } func runUnloadUnit(args []string) (exit int) { + if len(args) == 0 { + stderr("One unit file must be provided.") + return 1 + } units, err := findUnits(args) if err != nil { stderr("%v", err)