|
@@ -3,11 +3,22 @@ package cli_options
|
|
|
import (
|
|
|
"errors"
|
|
|
|
|
|
+ "github.com/gravitl/netmaker/logger"
|
|
|
"github.com/gravitl/netmaker/netclient/command"
|
|
|
"github.com/gravitl/netmaker/netclient/config"
|
|
|
"github.com/urfave/cli/v2"
|
|
|
)
|
|
|
|
|
|
+func parseVerbosity(c *cli.Context) {
|
|
|
+ if c.Bool("V") {
|
|
|
+ logger.Verbosity = 1
|
|
|
+ } else if c.Bool("VV") {
|
|
|
+ logger.Verbosity = 2
|
|
|
+ } else if c.Bool("VVV") {
|
|
|
+ logger.Verbosity = 3
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// GetCommands - return commands that CLI uses
|
|
|
func GetCommands(cliFlags []cli.Flag) []*cli.Command {
|
|
|
return []*cli.Command{
|
|
@@ -16,6 +27,7 @@ func GetCommands(cliFlags []cli.Flag) []*cli.Command {
|
|
|
Usage: "Join a Netmaker network.",
|
|
|
Flags: cliFlags,
|
|
|
Action: func(c *cli.Context) error {
|
|
|
+ parseVerbosity(c)
|
|
|
cfg, pvtKey, err := config.GetCLIConfig(c)
|
|
|
if err != nil {
|
|
|
return err
|
|
@@ -39,6 +51,7 @@ func GetCommands(cliFlags []cli.Flag) []*cli.Command {
|
|
|
// the action, or code that will be executed when
|
|
|
// we execute our `ns` command
|
|
|
Action: func(c *cli.Context) error {
|
|
|
+ parseVerbosity(c)
|
|
|
cfg, _, err := config.GetCLIConfig(c)
|
|
|
if err != nil {
|
|
|
return err
|
|
@@ -54,6 +67,7 @@ func GetCommands(cliFlags []cli.Flag) []*cli.Command {
|
|
|
// the action, or code that will be executed when
|
|
|
// we execute our `ns` command
|
|
|
Action: func(c *cli.Context) error {
|
|
|
+ parseVerbosity(c)
|
|
|
cfg, _, err := config.GetCLIConfig(c)
|
|
|
if err != nil {
|
|
|
return err
|
|
@@ -69,6 +83,7 @@ func GetCommands(cliFlags []cli.Flag) []*cli.Command {
|
|
|
// the action, or code that will be executed when
|
|
|
// we execute our `ns` command
|
|
|
Action: func(c *cli.Context) error {
|
|
|
+ parseVerbosity(c)
|
|
|
cfg, _, err := config.GetCLIConfig(c)
|
|
|
if err != nil {
|
|
|
return err
|
|
@@ -84,6 +99,7 @@ func GetCommands(cliFlags []cli.Flag) []*cli.Command {
|
|
|
// the action, or code that will be executed when
|
|
|
// we execute our `ns` command
|
|
|
Action: func(c *cli.Context) error {
|
|
|
+ parseVerbosity(c)
|
|
|
err := command.Uninstall()
|
|
|
return err
|
|
|
},
|
|
@@ -93,6 +109,8 @@ func GetCommands(cliFlags []cli.Flag) []*cli.Command {
|
|
|
Usage: "run netclient as daemon",
|
|
|
Flags: cliFlags,
|
|
|
Action: func(c *cli.Context) error {
|
|
|
+ // set max verbosity for daemon regardless
|
|
|
+ logger.Verbosity = 3
|
|
|
err := command.Daemon()
|
|
|
return err
|
|
|
},
|