MSP-5014 Move flag package to command
This commit is contained in:
1 parent
24a6522d57
commit
599fa22429
11 files changed
+9
-9
No files matched your search
+1
-1
@@ -6,8 +6,8 @@ import (
|
||||
"github.com/tidwall/sjson"
|
||||
"github.com/urfave/cli/v2"
|
||||
"ispctl/bash"
|
||||
"ispctl/command/flag"
|
||||
"ispctl/command/utils"
|
||||
"ispctl/flag"
|
||||
"ispctl/service"
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package flag
|
||||
|
||||
import "fmt"
|
||||
|
||||
const (
|
||||
hostName = "gateHost"
|
||||
hostUsage = "isp-config-service address"
|
||||
|
||||
unsafeName = "unsafe"
|
||||
unsafeUsage = "disable checking schema for set configuration"
|
||||
|
||||
outPrintName = "o"
|
||||
OutPrintJsonValue = "json"
|
||||
OutPrintHtmlValue = "html"
|
||||
|
||||
secretVariableName = "secret"
|
||||
)
|
||||
|
||||
var (
|
||||
outPrintStatusUsage = fmt.Sprintf("out print for status; %s", OutPrintJsonValue)
|
||||
outPrintSchemaUsage = fmt.Sprintf("out print for schema; %s or %s", OutPrintJsonValue, OutPrintHtmlValue)
|
||||
secretVariableUsage = "set variable as secret"
|
||||
)
|
||||
@@ -0,0 +1,38 @@
|
||||
package flag
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"ispctl/service"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var (
|
||||
//---global---
|
||||
Host = &cli.StringFlag{
|
||||
Name: hostName,
|
||||
Usage: hostUsage,
|
||||
Value: "127.0.0.1:9002",
|
||||
Required: false,
|
||||
Aliases: []string{"g", "configAddr"},
|
||||
}
|
||||
Unsafe = &cli.BoolFlag{Name: unsafeName, Usage: unsafeUsage}
|
||||
//---local---
|
||||
OutPrintStatus = &cli.StringFlag{Name: outPrintName, Usage: outPrintStatusUsage}
|
||||
OutPrintSchema = &cli.StringFlag{Name: outPrintName, Usage: outPrintSchemaUsage, Value: OutPrintJsonValue}
|
||||
|
||||
SetVariableSecretType = &cli.BoolFlag{Name: secretVariableName, Usage: secretVariableUsage}
|
||||
)
|
||||
|
||||
func CheckGlobal(c *cli.Context) error {
|
||||
var (
|
||||
host string
|
||||
)
|
||||
service.Config.UnsafeEnable = c.Bool(Unsafe.Name)
|
||||
|
||||
host = c.String(Host.Name)
|
||||
host = strings.Replace(host, "'", "", -1)
|
||||
|
||||
return service.Config.ReceiveConfiguration(host)
|
||||
}
|
||||
+1
-1
@@ -5,8 +5,8 @@ import (
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
"ispctl/bash"
|
||||
"ispctl/command/flag"
|
||||
"ispctl/command/utils"
|
||||
"ispctl/flag"
|
||||
"ispctl/service"
|
||||
)
|
||||
|
||||
|
||||
+1
-1
@@ -7,8 +7,8 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli/v2"
|
||||
"ispctl/bash"
|
||||
"ispctl/command/flag"
|
||||
"ispctl/command/utils"
|
||||
"ispctl/flag"
|
||||
"ispctl/service"
|
||||
)
|
||||
|
||||
|
||||
+1
-1
@@ -7,8 +7,8 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli/v2"
|
||||
"ispctl/bash"
|
||||
"ispctl/command/flag"
|
||||
"ispctl/command/utils"
|
||||
"ispctl/flag"
|
||||
"ispctl/service"
|
||||
"ispctl/tmpl"
|
||||
)
|
||||
|
||||
+1
-1
@@ -6,8 +6,8 @@ import (
|
||||
"github.com/tidwall/sjson"
|
||||
"github.com/urfave/cli/v2"
|
||||
"ispctl/bash"
|
||||
"ispctl/command/flag"
|
||||
"ispctl/command/utils"
|
||||
"ispctl/flag"
|
||||
"ispctl/service"
|
||||
)
|
||||
|
||||
|
||||
+1
-1
@@ -7,8 +7,8 @@ import (
|
||||
|
||||
"github.com/olekukonko/tablewriter"
|
||||
"github.com/urfave/cli/v2"
|
||||
"ispctl/command/flag"
|
||||
"ispctl/command/utils"
|
||||
"ispctl/flag"
|
||||
"ispctl/service"
|
||||
)
|
||||
|
||||
|
||||
+1
-1
@@ -5,8 +5,8 @@ import (
|
||||
"fmt"
|
||||
"ispctl/bash"
|
||||
"ispctl/cfg"
|
||||
"ispctl/command/flag"
|
||||
"ispctl/command/utils"
|
||||
"ispctl/flag"
|
||||
"ispctl/service"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
Reference in new issue
Block a user