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:
Ian Howell 2019-06-07 14:06:33 -05:00
parent eb79dff0c9
commit 236274eef1
2 changed files with 7 additions and 3 deletions

View File

@ -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) {

View File

@ -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)