diff --git a/cmd/api/main.go b/cmd/api/main.go index 88ba7c7..27cb25c 100644 --- a/cmd/api/main.go +++ b/cmd/api/main.go @@ -1,8 +1,38 @@ -// Package main provides the nightd API control plane. +// Package main provides the nightd API control plane CLI. package main -import "fmt" +import ( + "fmt" + "os" + + "github.com/spf13/cobra" +) + +var rootCmd = &cobra.Command{ + Use: "api", + Short: "nightd API", + Long: "The nightd API manages Omnigent servers and routing.", + SilenceUsage: true, + Run: func(cmd *cobra.Command, _ []string) { + _, _ = fmt.Fprintln(cmd.OutOrStdout(), "nightd API - use 'api start' to run") + }, +} + +var startCmd = &cobra.Command{ + Use: "start", + Short: "Start the API", + Run: func(cmd *cobra.Command, _ []string) { + _, _ = fmt.Fprintln(cmd.OutOrStdout(), "nightd API started") + }, +} + +func init() { + rootCmd.AddCommand(startCmd) +} func main() { - fmt.Println("nightd API control plane") + if err := rootCmd.Execute(); err != nil { + _, _ = fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } } diff --git a/cmd/gateway/main.go b/cmd/gateway/main.go index 95a4efa..85be363 100644 --- a/cmd/gateway/main.go +++ b/cmd/gateway/main.go @@ -1,8 +1,38 @@ -// Package main provides the nightd gateway proxy. +// Package main provides the nightd gateway proxy CLI. package main -import "fmt" +import ( + "fmt" + "os" + + "github.com/spf13/cobra" +) + +var rootCmd = &cobra.Command{ + Use: "gateway", + Short: "nightd gateway", + Long: "The nightd gateway proxies authenticated requests to the correct Omnigent server for a workspace.", + SilenceUsage: true, + Run: func(cmd *cobra.Command, _ []string) { + _, _ = fmt.Fprintln(cmd.OutOrStdout(), "nightd gateway - use 'gateway start' to run") + }, +} + +var startCmd = &cobra.Command{ + Use: "start", + Short: "Start the gateway", + Run: func(cmd *cobra.Command, _ []string) { + _, _ = fmt.Fprintln(cmd.OutOrStdout(), "nightd gateway started") + }, +} + +func init() { + rootCmd.AddCommand(startCmd) +} func main() { - fmt.Println("nightd gateway proxy") + if err := rootCmd.Execute(); err != nil { + _, _ = fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } } diff --git a/cmd/node/main.go b/cmd/node/main.go index ad9cc67..cba18fe 100644 --- a/cmd/node/main.go +++ b/cmd/node/main.go @@ -1,8 +1,38 @@ -// Package main provides the nightd node data plane. +// Package main provides the nightd node data plane CLI. package main -import "fmt" +import ( + "fmt" + "os" + + "github.com/spf13/cobra" +) + +var rootCmd = &cobra.Command{ + Use: "node", + Short: "nightd node", + Long: "The nightd node launches an Omnigent server for a specified workspace.", + SilenceUsage: true, + Run: func(cmd *cobra.Command, _ []string) { + _, _ = fmt.Fprintln(cmd.OutOrStdout(), "nightd node - use 'node start' to run") + }, +} + +var startCmd = &cobra.Command{ + Use: "start", + Short: "Start the node", + Run: func(cmd *cobra.Command, _ []string) { + _, _ = fmt.Fprintln(cmd.OutOrStdout(), "nightd node started") + }, +} + +func init() { + rootCmd.AddCommand(startCmd) +} func main() { - fmt.Println("nightd node data plane") + if err := rootCmd.Execute(); err != nil { + _, _ = fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } } diff --git a/mise.toml b/mise.toml index 528ed2f..0809538 100644 --- a/mise.toml +++ b/mise.toml @@ -12,13 +12,13 @@ depends = ["up"] run = ["gofmt -l .", "go build ./...", "golangci-lint run", "go test ./..."] [tasks."dev:api"] -run = "go run ./cmd/api" +run = "go run ./cmd/api start" [tasks."dev:gateway"] -run = "go run ./cmd/gateway" +run = "go run ./cmd/gateway start" [tasks."dev:node"] -run = "go run ./cmd/node" +run = "go run ./cmd/node start" [tasks.docs] run = "uvx zensical build --clean"