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

Commit

Permalink
fleetctl: Add the args check for some subcommand
Browse files Browse the repository at this point in the history
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
  • Loading branch information
wuqixuan committed May 17, 2015
1 parent f1d86c7 commit 57ec7b1
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fleetctl/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ Destroyed units are impossible to start unless re-submitted.`,
}

func runDestroyUnits(args []string) (exit int) {
if len(args) != 1 {
stderr("One unit file must be provided.")
return 1
}
for _, v := range args {
name := unitNameMangle(v)
err := cAPI.DestroyUnit(name)
Expand Down
4 changes: 4 additions & 0 deletions fleetctl/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ func init() {
}

func runLoadUnits(args []string) (exit int) {
if len(args) != 1 {
stderr("One unit file must be provided.")
return 1
}
if err := lazyCreateUnits(args); err != nil {
stderr("Error creating units: %v", err)
return 1
Expand Down
4 changes: 4 additions & 0 deletions fleetctl/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ func init() {
}

func runStartUnit(args []string) (exit int) {
if len(args) != 1 {
stderr("One unit file must be provided.")
return 1
}
if err := lazyCreateUnits(args); err != nil {
stderr("Error creating units: %v", err)
return 1
Expand Down
4 changes: 4 additions & 0 deletions fleetctl/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ func init() {
}

func runStatusUnits(args []string) (exit int) {
if len(args) != 1 {
stderr("One unit file must be provided.")
return 1
}
units, err := cAPI.Units()
if err != nil {
stderr("Error retrieving unit: %v", err)
Expand Down
4 changes: 4 additions & 0 deletions fleetctl/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ func init() {
}

func runStopUnit(args []string) (exit int) {
if len(args) != 1 {
stderr("One unit file must be provided.")
return 1
}
units, err := findUnits(args)
if err != nil {
stderr("%v", err)
Expand Down
4 changes: 4 additions & 0 deletions fleetctl/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ func init() {
}

func runSubmitUnits(args []string) (exit int) {
if len(args) != 1 {
stderr("One unit file must be provided.")
return 1
}
if err := lazyCreateUnits(args); err != nil {
stderr("Error creating units: %v", err)
exit = 1
Expand Down
4 changes: 4 additions & 0 deletions fleetctl/unload.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ func init() {
}

func runUnloadUnit(args []string) (exit int) {
if len(args) != 1 {
stderr("One unit file must be provided.")
return 1
}
units, err := findUnits(args)
if err != nil {
stderr("%v", err)
Expand Down

0 comments on commit 57ec7b1

Please sign in to comment.