'zrok daemon' cli skeleton (#463)

This commit is contained in:
Michael Quigley 2024-08-12 11:35:57 -04:00
parent 3ddbcbd7e7
commit 8863ea1b67
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62

37
cmd/zrok/daemon.go Normal file
View File

@ -0,0 +1,37 @@
package main
import (
"github.com/openziti/zrok/environment"
"github.com/openziti/zrok/tui"
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(newDaemonCommand().cmd)
}
type daemonCommand struct {
cmd *cobra.Command
}
func newDaemonCommand() *daemonCommand {
cmd := &cobra.Command{
Use: "daemon",
Short: "Launch a zrok daemon",
Args: cobra.NoArgs,
}
command := &daemonCommand{cmd: cmd}
cmd.Run = command.run
return command
}
func (cmd *daemonCommand) run(_ *cobra.Command, _ []string) {
root, err := environment.LoadRoot()
if err != nil {
tui.Error("error loading zrokdir", err)
}
if !root.IsEnabled() {
tui.Error("unable to load environment; did you 'zrok enable'?", nil)
}
}