mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-03-09 20:59:02 +00:00
* simv2: wip * simulation: exec adapter start/stop * simulation: add node status to exec adapter * simulation: initial simulation code * simulation: exec adapter, configure path to executable * simulation: initial docker adapter * simulation: wip kubernetes adapter * simulation: kubernetes adapter proxy * simulation: implement GetAll/StartAll/StopAll * simulation: kuberentes adapter - set env vars and resource limits * simulation: discovery test * simulation: remove port definitions within docker adapter * simulation: simplify wait for healthy loop * simulation: get nat ip addr from interface * simulation: pull docker images automatically * simulation: NodeStatus -> NodeInfo * simulation: move discovery test to example dir * simulation: example snapshot usage * simulation: add goclient specific simulation * simulation: add peer connections to snapshot * simulation: close rpc client * simulation: don't export kubernetes proxy server * simulation: merge simulation code * simulation: don't export nodemap * simulation: rename SimulationSnapshot -> Snapshot * simulation: linting fixes * simulation: add k8s available helper func * simulation: vendor * simulation: fix 'no non-test Go files' when building * simulation: remove errors from interface methods where non were returned * simulation: run getHealthInfo check in parallel
86 lines
3.2 KiB
Go
86 lines
3.2 KiB
Go
package pflag
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// -- time.Duration Value
|
|
type durationValue time.Duration
|
|
|
|
func newDurationValue(val time.Duration, p *time.Duration) *durationValue {
|
|
*p = val
|
|
return (*durationValue)(p)
|
|
}
|
|
|
|
func (d *durationValue) Set(s string) error {
|
|
v, err := time.ParseDuration(s)
|
|
*d = durationValue(v)
|
|
return err
|
|
}
|
|
|
|
func (d *durationValue) Type() string {
|
|
return "duration"
|
|
}
|
|
|
|
func (d *durationValue) String() string { return (*time.Duration)(d).String() }
|
|
|
|
func durationConv(sval string) (interface{}, error) {
|
|
return time.ParseDuration(sval)
|
|
}
|
|
|
|
// GetDuration return the duration value of a flag with the given name
|
|
func (f *FlagSet) GetDuration(name string) (time.Duration, error) {
|
|
val, err := f.getFlagType(name, "duration", durationConv)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return val.(time.Duration), nil
|
|
}
|
|
|
|
// DurationVar defines a time.Duration flag with specified name, default value, and usage string.
|
|
// The argument p points to a time.Duration variable in which to store the value of the flag.
|
|
func (f *FlagSet) DurationVar(p *time.Duration, name string, value time.Duration, usage string) {
|
|
f.VarP(newDurationValue(value, p), name, "", usage)
|
|
}
|
|
|
|
// DurationVarP is like DurationVar, but accepts a shorthand letter that can be used after a single dash.
|
|
func (f *FlagSet) DurationVarP(p *time.Duration, name, shorthand string, value time.Duration, usage string) {
|
|
f.VarP(newDurationValue(value, p), name, shorthand, usage)
|
|
}
|
|
|
|
// DurationVar defines a time.Duration flag with specified name, default value, and usage string.
|
|
// The argument p points to a time.Duration variable in which to store the value of the flag.
|
|
func DurationVar(p *time.Duration, name string, value time.Duration, usage string) {
|
|
CommandLine.VarP(newDurationValue(value, p), name, "", usage)
|
|
}
|
|
|
|
// DurationVarP is like DurationVar, but accepts a shorthand letter that can be used after a single dash.
|
|
func DurationVarP(p *time.Duration, name, shorthand string, value time.Duration, usage string) {
|
|
CommandLine.VarP(newDurationValue(value, p), name, shorthand, usage)
|
|
}
|
|
|
|
// Duration defines a time.Duration flag with specified name, default value, and usage string.
|
|
// The return value is the address of a time.Duration variable that stores the value of the flag.
|
|
func (f *FlagSet) Duration(name string, value time.Duration, usage string) *time.Duration {
|
|
p := new(time.Duration)
|
|
f.DurationVarP(p, name, "", value, usage)
|
|
return p
|
|
}
|
|
|
|
// DurationP is like Duration, but accepts a shorthand letter that can be used after a single dash.
|
|
func (f *FlagSet) DurationP(name, shorthand string, value time.Duration, usage string) *time.Duration {
|
|
p := new(time.Duration)
|
|
f.DurationVarP(p, name, shorthand, value, usage)
|
|
return p
|
|
}
|
|
|
|
// Duration defines a time.Duration flag with specified name, default value, and usage string.
|
|
// The return value is the address of a time.Duration variable that stores the value of the flag.
|
|
func Duration(name string, value time.Duration, usage string) *time.Duration {
|
|
return CommandLine.DurationP(name, "", value, usage)
|
|
}
|
|
|
|
// DurationP is like Duration, but accepts a shorthand letter that can be used after a single dash.
|
|
func DurationP(name, shorthand string, value time.Duration, usage string) *time.Duration {
|
|
return CommandLine.DurationP(name, shorthand, value, usage)
|
|
}
|