mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
Revert "internal/flags: fix loading env vars for custom flags (#28117)"
This reverts commit cd0e8a5ec9.
This commit is contained in:
parent
b2f8d19976
commit
7e008abc3d
1 changed files with 0 additions and 30 deletions
|
|
@ -20,13 +20,11 @@ import (
|
||||||
"encoding"
|
"encoding"
|
||||||
"errors"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common/math"
|
"github.com/ethereum/go-ethereum/common/math"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
|
@ -82,14 +80,6 @@ func (f *DirectoryFlag) String() string { return cli.FlagStringer(f) }
|
||||||
// Apply called by cli library, grabs variable from environment (if in env)
|
// Apply called by cli library, grabs variable from environment (if in env)
|
||||||
// and adds variable to flag set for parsing.
|
// and adds variable to flag set for parsing.
|
||||||
func (f *DirectoryFlag) Apply(set *flag.FlagSet) error {
|
func (f *DirectoryFlag) Apply(set *flag.FlagSet) error {
|
||||||
for _, envVar := range f.EnvVars {
|
|
||||||
envVar = strings.TrimSpace(envVar)
|
|
||||||
if value, found := syscall.Getenv(envVar); found {
|
|
||||||
f.Value.Set(value)
|
|
||||||
f.HasBeenSet = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
eachName(f, func(name string) {
|
eachName(f, func(name string) {
|
||||||
set.Var(&f.Value, f.Name, f.Usage)
|
set.Var(&f.Value, f.Name, f.Usage)
|
||||||
})
|
})
|
||||||
|
|
@ -177,16 +167,6 @@ func (f *TextMarshalerFlag) IsSet() bool { return f.HasBeenSet }
|
||||||
func (f *TextMarshalerFlag) String() string { return cli.FlagStringer(f) }
|
func (f *TextMarshalerFlag) String() string { return cli.FlagStringer(f) }
|
||||||
|
|
||||||
func (f *TextMarshalerFlag) Apply(set *flag.FlagSet) error {
|
func (f *TextMarshalerFlag) Apply(set *flag.FlagSet) error {
|
||||||
for _, envVar := range f.EnvVars {
|
|
||||||
envVar = strings.TrimSpace(envVar)
|
|
||||||
if value, found := syscall.Getenv(envVar); found {
|
|
||||||
if err := f.Value.UnmarshalText([]byte(value)); err != nil {
|
|
||||||
return fmt.Errorf("could not parse %q from environment variable %q for flag %s: %s", value, envVar, f.Name, err)
|
|
||||||
}
|
|
||||||
f.HasBeenSet = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
eachName(f, func(name string) {
|
eachName(f, func(name string) {
|
||||||
set.Var(textMarshalerVal{f.Value}, f.Name, f.Usage)
|
set.Var(textMarshalerVal{f.Value}, f.Name, f.Usage)
|
||||||
})
|
})
|
||||||
|
|
@ -269,16 +249,6 @@ func (f *BigFlag) IsSet() bool { return f.HasBeenSet }
|
||||||
func (f *BigFlag) String() string { return cli.FlagStringer(f) }
|
func (f *BigFlag) String() string { return cli.FlagStringer(f) }
|
||||||
|
|
||||||
func (f *BigFlag) Apply(set *flag.FlagSet) error {
|
func (f *BigFlag) Apply(set *flag.FlagSet) error {
|
||||||
for _, envVar := range f.EnvVars {
|
|
||||||
envVar = strings.TrimSpace(envVar)
|
|
||||||
if value, found := syscall.Getenv(envVar); found {
|
|
||||||
if _, ok := f.Value.SetString(value, 10); !ok {
|
|
||||||
return fmt.Errorf("could not parse %q from environment variable %q for flag %s", value, envVar, f.Name)
|
|
||||||
}
|
|
||||||
f.HasBeenSet = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
eachName(f, func(name string) {
|
eachName(f, func(name string) {
|
||||||
f.Value = new(big.Int)
|
f.Value = new(big.Int)
|
||||||
set.Var((*bigValue)(f.Value), f.Name, f.Usage)
|
set.Var((*bigValue)(f.Value), f.Name, f.Usage)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue