Skip to content

Commit

Permalink
'zrok daemon' cli skeleton (#463)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelquigley committed Aug 12, 2024
1 parent 3ddbcbd commit 8863ea1
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions cmd/zrok/daemon.go
Original file line number Diff line number Diff line change
@@ -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)
}
}

0 comments on commit 8863ea1

Please sign in to comment.