Files
WarpBox/cmd/main.go

40 lines
803 B
Go
Raw Normal View History

package main
import (
"fmt"
"os"
"github.com/spf13/cobra"
"warpbox/lib/server"
)
func main() {
if err := newRootCommand().Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
func newRootCommand() *cobra.Command {
rootCmd := &cobra.Command{
Use: "warpbox",
Short: "WarpBox command line interface",
Long: "WarpBox provides commands for running and managing the WarpBox service.",
}
var addr string
runCmd := &cobra.Command{
Use: "run",
Short: "Run the HTTP server",
Long: "Run the WarpBox HTTP server. The root endpoint responds with ok.",
RunE: func(cmd *cobra.Command, args []string) error {
return server.Run(addr)
},
}
runCmd.Flags().StringVar(&addr, "addr", ":8080", "HTTP server address")
rootCmd.AddCommand(runCmd)
return rootCmd
}