mirror of
https://github.com/openziti/zrok.git
synced 2025-06-20 01:37:52 +02:00
'zrok daemon' cli skeleton (#463)
This commit is contained in:
parent
3ddbcbd7e7
commit
8863ea1b67
37
cmd/zrok/daemon.go
Normal file
37
cmd/zrok/daemon.go
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user