-
Notifications
You must be signed in to change notification settings - Fork 302
fleetctl: Need return fail if no args given to some subcommand. #1230
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,10 @@ func init() { | |
} | ||
|
||
func runLoadUnits(args []string) (exit int) { | ||
if len(args) == 0 { | ||
stderr("One unit file must be provided.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,10 @@ func init() { | |
} | ||
|
||
func runStartUnit(args []string) (exit int) { | ||
if len(args) == 0 { | ||
stderr("One unit file must be provided.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,10 @@ func init() { | |
} | ||
|
||
func runStatusUnits(args []string) (exit int) { | ||
if len(args) == 0 { | ||
stderr("One unit file must be provided.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,12 +52,22 @@ func init() { | |
} | ||
|
||
func runStopUnit(args []string) (exit int) { | ||
if len(args) == 0 { | ||
stderr("One unit file must be provided.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,10 @@ func init() { | |
} | ||
|
||
func runSubmitUnits(args []string) (exit int) { | ||
if len(args) == 0 { | ||
stderr("One unit file must be provided.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,10 @@ func init() { | |
} | ||
|
||
func runUnloadUnit(args []string) (exit int) { | ||
if len(args) == 0 { | ||
stderr("One unit file must be provided.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
There was a problem hiding this comment.
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