From 8863ea1b67b3229973f3d9abd94f1d3803b9d37d Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Mon, 12 Aug 2024 11:35:57 -0400 Subject: [PATCH] 'zrok daemon' cli skeleton (#463) --- cmd/zrok/daemon.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 cmd/zrok/daemon.go diff --git a/cmd/zrok/daemon.go b/cmd/zrok/daemon.go new file mode 100644 index 00000000..c2977b17 --- /dev/null +++ b/cmd/zrok/daemon.go @@ -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) + } +}