spud/main.go

45 lines
890 B
Go

package main
import (
"github.com/spf13/cobra"
"log"
service "spud/service"
service_definition "spud/service_definition"
)
var cli = &cobra.Command{
Use: "spud",
Short: "A not-entirely-terrible-way to manage self-hosted services.",
}
var start = &cobra.Command{
Use: "start",
Short: "Creates or updates a service based on the provided definition.",
Run: func(cmd *cobra.Command, args []string) {
pathProvided := args[0]
def, err := service_definition.GetServiceDefinitionFromFile(pathProvided)
if err != nil {
log.Fatal(err)
}
service.CreateService(def)
},
}
var stop = &cobra.Command{
Use: "stop",
Short: "Stops a running service and all of its containers.",
Run: func(cmd *cobra.Command, args []string) {
serviceName := args[0]
service.StopService(serviceName)
},
}
func main() {
cli.AddCommand(start)
cli.AddCommand(stop)
cli.Execute()
}