-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ddbcbd
commit 8863ea1
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |