diff --git a/cmd/root.go b/cmd/root.go index c3f2e6e4e..2bde0d545 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -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) { diff --git a/main.go b/main.go index 1fd987646..51f0ac110 100644 --- a/main.go +++ b/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)