Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit f70fb15

Browse files
author
wuqixuan
committed
fleetctl: Add the args check for some subcommand
Some subcommand like destroy/load/start/status/stop/submit/unload, need to give prompt if no args for them. Add the same prompt "One unit file must be provided" as the "cat" subcommand is doing: [root@localhost fleet-0.10.1]# fleetctl cat One unit file must be provided
1 parent f1d86c7 commit f70fb15

File tree

7 files changed

+28
-0
lines changed

7 files changed

+28
-0
lines changed

Diff for: fleetctl/destroy.go

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ Destroyed units are impossible to start unless re-submitted.`,
2929
}
3030

3131
func runDestroyUnits(args []string) (exit int) {
32+
if len(args) == 0 {
33+
stderr("One unit file must be provided.")
34+
return 1
35+
}
3236
for _, v := range args {
3337
name := unitNameMangle(v)
3438
err := cAPI.DestroyUnit(name)

Diff for: fleetctl/load.go

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ func init() {
4646
}
4747

4848
func runLoadUnits(args []string) (exit int) {
49+
if len(args) == 0 {
50+
stderr("One unit file must be provided.")
51+
return 1
52+
}
4953
if err := lazyCreateUnits(args); err != nil {
5054
stderr("Error creating units: %v", err)
5155
return 1

Diff for: fleetctl/start.go

+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ func init() {
5454
}
5555

5656
func runStartUnit(args []string) (exit int) {
57+
if len(args) == 0 {
58+
stderr("One unit file must be provided.")
59+
return 1
60+
}
5761
if err := lazyCreateUnits(args); err != nil {
5862
stderr("Error creating units: %v", err)
5963
return 1

Diff for: fleetctl/status.go

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ func init() {
4444
}
4545

4646
func runStatusUnits(args []string) (exit int) {
47+
if len(args) == 0 {
48+
stderr("One unit file must be provided.")
49+
return 1
50+
}
4751
units, err := cAPI.Units()
4852
if err != nil {
4953
stderr("Error retrieving unit: %v", err)

Diff for: fleetctl/stop.go

+4
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ func init() {
5252
}
5353

5454
func runStopUnit(args []string) (exit int) {
55+
if len(args) == 0 {
56+
stderr("One unit file must be provided.")
57+
return 1
58+
}
5559
units, err := findUnits(args)
5660
if err != nil {
5761
stderr("%v", err)

Diff for: fleetctl/submit.go

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ func init() {
3636
}
3737

3838
func runSubmitUnits(args []string) (exit int) {
39+
if len(args) == 0 {
40+
stderr("One unit file must be provided.")
41+
return 1
42+
}
3943
if err := lazyCreateUnits(args); err != nil {
4044
stderr("Error creating units: %v", err)
4145
exit = 1

Diff for: fleetctl/unload.go

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ func init() {
3636
}
3737

3838
func runUnloadUnit(args []string) (exit int) {
39+
if len(args) == 0 {
40+
stderr("One unit file must be provided.")
41+
return 1
42+
}
3943
units, err := findUnits(args)
4044
if err != nil {
4145
stderr("%v", err)

0 commit comments

Comments
 (0)