Add a convenience NewAirshipCTLCommand function
This adds the NewAirshipCTLCommand, a function which returns the root airshipctl command with all of the default plugins preloaded
This commit is contained in:
parent
eb79dff0c9
commit
236274eef1
@ -11,6 +11,12 @@ import (
|
||||
"github.com/ian-howell/airshipctl/pkg/log"
|
||||
)
|
||||
|
||||
// NewAirshipCTLCommand creates a root `airshipctl` command with the default commands attached
|
||||
func NewAirshipCTLCommand(out io.Writer) (*cobra.Command, *environment.AirshipCTLSettings, error) {
|
||||
rootCmd, settings, err := NewRootCmd(out)
|
||||
return AddDefaultAirshipCTLCommands(rootCmd, settings), settings, err
|
||||
}
|
||||
|
||||
// NewRootCmd creates the root `airshipctl` command. All other commands are
|
||||
// subcommands branching from this one
|
||||
func NewRootCmd(out io.Writer) (*cobra.Command, *environment.AirshipCTLSettings, error) {
|
||||
|
4
main.go
4
main.go
@ -8,14 +8,12 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
rootCmd, settings, err := cmd.NewRootCmd(os.Stdout)
|
||||
rootCmd, _, err := cmd.NewAirshipCTLCommand(os.Stdout)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stdout, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
cmd.AddDefaultAirshipCTLCommands(rootCmd, settings)
|
||||
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
fmt.Fprintln(os.Stdout, err)
|
||||
os.Exit(1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user