Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
add site commands
Browse files Browse the repository at this point in the history
Signed-off-by: Jason McCallister <jason@craftcms.com>
  • Loading branch information
jasonmccallister committed Apr 3, 2020
1 parent bce01d7 commit b9d23a4
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
33 changes: 33 additions & 0 deletions cmd/next/cmd/site.go
Original file line number Diff line number Diff line change
@@ -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)
}
},
}
28 changes: 28 additions & 0 deletions cmd/next/cmd/site_add.go
Original file line number Diff line number Diff line change
@@ -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)
}
},
}
28 changes: 28 additions & 0 deletions cmd/next/cmd/site_remove.go
Original file line number Diff line number Diff line change
@@ -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)
}
},
}
8 changes: 8 additions & 0 deletions internal/nitro/empty.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package nitro

import "fmt"

func Empty(name string) []Command {
fmt.Println("this is empty!", name)
return nil
}

0 comments on commit b9d23a4

Please # to comment.