chore(cmd): Remove IntVar and move to Int64Var
This commit is contained in:
1 parent
3195dcba4e
commit
bf9dbd818e
6 files changed
+13
-77
No files matched your search
@@ -128,7 +128,7 @@ type Command struct {
|
||||
FlagAuthMethodId string
|
||||
FlagHostCatalogId string
|
||||
FlagCredentialStoreId string
|
||||
FlagVersion int
|
||||
FlagVersion int64
|
||||
FlagRecursive bool
|
||||
FlagFilter string
|
||||
FlagTags map[string][]string
|
||||
|
||||
@@ -98,70 +98,6 @@ func (b *boolValue) Example() string { return "" }
|
||||
func (b *boolValue) Hidden() bool { return b.hidden }
|
||||
func (b *boolValue) IsBoolFlag() bool { return true }
|
||||
|
||||
// -- IntVar and intValue
|
||||
type IntVar struct {
|
||||
Name string
|
||||
Aliases []string
|
||||
Usage string
|
||||
Default int
|
||||
Hidden bool
|
||||
EnvVar string
|
||||
Target *int
|
||||
Completion complete.Predictor
|
||||
}
|
||||
|
||||
func (f *FlagSet) IntVar(i *IntVar) {
|
||||
initial := i.Default
|
||||
if v, exist := os.LookupEnv(i.EnvVar); exist {
|
||||
if i, err := strconv.ParseInt(v, 0, 64); err == nil {
|
||||
initial = int(i)
|
||||
}
|
||||
}
|
||||
|
||||
def := ""
|
||||
if i.Default != 0 {
|
||||
def = strconv.FormatInt(int64(i.Default), 10)
|
||||
}
|
||||
|
||||
f.VarFlag(&VarFlag{
|
||||
Name: i.Name,
|
||||
Aliases: i.Aliases,
|
||||
Usage: i.Usage,
|
||||
Default: def,
|
||||
EnvVar: i.EnvVar,
|
||||
Value: newIntValue(initial, i.Target, i.Hidden),
|
||||
Completion: i.Completion,
|
||||
})
|
||||
}
|
||||
|
||||
type intValue struct {
|
||||
hidden bool
|
||||
target *int
|
||||
}
|
||||
|
||||
func newIntValue(def int, target *int, hidden bool) *intValue {
|
||||
*target = def
|
||||
return &intValue{
|
||||
hidden: hidden,
|
||||
target: target,
|
||||
}
|
||||
}
|
||||
|
||||
func (i *intValue) Set(s string) error {
|
||||
v, err := strconv.ParseInt(s, 0, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*i.target = int(v)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *intValue) Get() any { return int(*i.target) }
|
||||
func (i *intValue) String() string { return strconv.Itoa(int(*i.target)) }
|
||||
func (i *intValue) Example() string { return "int" }
|
||||
func (i *intValue) Hidden() bool { return i.hidden }
|
||||
|
||||
// -- Int64Var and int64Value
|
||||
type Int64Var struct {
|
||||
Name string
|
||||
|
||||
@@ -122,9 +122,9 @@ type Server struct {
|
||||
DevSecondaryTargetId string // Target using host sources.
|
||||
DevHostAddress string // Host address for target using host sources.
|
||||
DevTargetAddress string // Network address for target with address.
|
||||
DevTargetDefaultPort int
|
||||
DevTargetSessionMaxSeconds int
|
||||
DevTargetSessionConnectionLimit int
|
||||
DevTargetDefaultPort int64
|
||||
DevTargetSessionMaxSeconds int64
|
||||
DevTargetSessionConnectionLimit int64
|
||||
DevLoopbackPluginId string
|
||||
|
||||
EnabledPlugins []EnabledPlugin
|
||||
|
||||
Reference in new issue
Block a user