spud/main.go

46 lines
890 B
Go
Raw Permalink Normal View History

2024-06-02 05:11:56 +00:00
package main
import (
"github.com/spf13/cobra"
2024-06-02 06:03:47 +00:00
"log"
service "spud/service"
service_definition "spud/service_definition"
2024-06-02 05:11:56 +00:00
)
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]
2024-06-02 06:03:47 +00:00
def, err := service_definition.GetServiceDefinitionFromFile(pathProvided)
if err != nil {
log.Fatal(err)
}
service.CreateService(def)
2024-06-02 05:11:56 +00:00
},
}
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)
},
}
2024-06-02 05:11:56 +00:00
func main() {
cli.AddCommand(start)
cli.AddCommand(stop)
2024-06-02 05:11:56 +00:00
cli.Execute()
}