diff --git a/Makefile b/Makefile index 0b8fb16d..c0a05a2b 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ MACHINE ?= demo-app build: - go build -o nitro ./cmd/nitro + go build -o nitro ./cmd/next run: build ./nitro init clean: diff --git a/cmd/next/cmd/site.go b/cmd/next/cmd/site.go new file mode 100644 index 00000000..2ff10d87 --- /dev/null +++ b/cmd/next/cmd/site.go @@ -0,0 +1,33 @@ +package cmd + +import ( + "log" + + "github.com/spf13/cobra" + + "github.com/craftcms/nitro/command" + "github.com/craftcms/nitro/internal/nitro" +) + +func init() { + rootCmd.AddCommand(siteCommand) + siteCommand.Flags().StringVar(&flagMachineName, "machine", "", "name of machine") +} + +var siteCommand = &cobra.Command{ + Use: "site", + Short: "Perform site commands", + Run: func(cmd *cobra.Command, args []string) { + if len(args) == 0 { + cmd.Help() + return + } + + if err := nitro.Run( + command.NewMultipassRunner("multipass"), + nitro.Empty(flagMachineName), + ); err != nil { + log.Fatal(err) + } + }, +} diff --git a/cmd/next/cmd/site_add.go b/cmd/next/cmd/site_add.go new file mode 100644 index 00000000..3a0491ef --- /dev/null +++ b/cmd/next/cmd/site_add.go @@ -0,0 +1,28 @@ +package cmd + +import ( + "log" + + "github.com/spf13/cobra" + + "github.com/craftcms/nitro/command" + "github.com/craftcms/nitro/internal/nitro" +) + +func init() { + siteCommand.AddCommand(siteAddCommand) + siteAddCommand.Flags().StringVar(&flagMachineName, "machine", "", "name of machine") +} + +var siteAddCommand = &cobra.Command{ + Use: "add", + Short: "Add a site to machine", + Run: func(cmd *cobra.Command, args []string) { + if err := nitro.Run( + command.NewMultipassRunner("multipass"), + nitro.Empty(flagMachineName), + ); err != nil { + log.Fatal(err) + } + }, +} diff --git a/cmd/next/cmd/site_remove.go b/cmd/next/cmd/site_remove.go new file mode 100644 index 00000000..f67c3a70 --- /dev/null +++ b/cmd/next/cmd/site_remove.go @@ -0,0 +1,28 @@ +package cmd + +import ( + "log" + + "github.com/spf13/cobra" + + "github.com/craftcms/nitro/command" + "github.com/craftcms/nitro/internal/nitro" +) + +func init() { + siteCommand.AddCommand(siteRemoveCommand) + siteRemoveCommand.Flags().StringVar(&flagMachineName, "machine", "", "name of machine") +} + +var siteRemoveCommand = &cobra.Command{ + Use: "remove", + Short: "Remove a site from machine", + Run: func(cmd *cobra.Command, args []string) { + if err := nitro.Run( + command.NewMultipassRunner("multipass"), + nitro.Empty(flagMachineName), + ); err != nil { + log.Fatal(err) + } + }, +} diff --git a/internal/nitro/empty.go b/internal/nitro/empty.go new file mode 100644 index 00000000..062d8536 --- /dev/null +++ b/internal/nitro/empty.go @@ -0,0 +1,8 @@ +package nitro + +import "fmt" + +func Empty(name string) []Command { + fmt.Println("this is empty!", name) + return nil +}