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

fleetctl: Need return fail if no args given to some subcommand. #1230

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) == 0 {
stderr("One unit file must be provided.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One or more unit files 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) == 0 {
stderr("One unit file must be provided.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One or more unit files 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) == 0 {
stderr("One unit file must be provided.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One or more unit files 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) == 0 {
stderr("One unit file must be provided.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One or more unit files must be provided

return 1
}
units, err := cAPI.Units()
if err != nil {
stderr("Error retrieving unit: %v", err)
Expand Down
10 changes: 10 additions & 0 deletions fleetctl/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,22 @@ func init() {
}

func runStopUnit(args []string) (exit int) {
if len(args) == 0 {
stderr("One unit file must be provided.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One or more unit files must be provided

return 1
}

units, err := findUnits(args)
if err != nil {
stderr("%v", err)
return 1
}

if len(units) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this check. The fleetctl commands are idempotent, so it is ok to do nothing.

stderr("The units to be stopped are not found in registry.")
return 1
}

stopping := make([]string, 0)
for _, u := range units {
if !suToGlobal(u) {
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) == 0 {
stderr("One unit file must be provided.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One or more unit files 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) == 0 {
stderr("One unit file must be provided.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One or more unit files must be provided

return 1
}
units, err := findUnits(args)
if err != nil {
stderr("%v", err)
Expand Down