cli: simplify option model per pike review
- appendList: one home for the List newline-join rule (was duplicated across accumulate and set) - fold the redundant Int64 getter into Int; drop the truthy helper for the shared boolWord vocabulary - add Opt.Metavar so help derives the value placeholder from data instead of branching on the option name (seed-time) No behavior change; --help output is byte-identical.
This commit is contained in:
@@ -48,13 +48,11 @@ func (o *Options) Bool(name string) bool {
|
||||
return val
|
||||
}
|
||||
|
||||
// Int returns the value as an int, or 0 if empty/invalid.
|
||||
func (o *Options) Int(name string) int { return int(o.Int64(name)) }
|
||||
|
||||
// Int64 returns the value as an int64, or 0 if empty/invalid.
|
||||
func (o *Options) Int64(name string) int64 {
|
||||
// Int returns the value as an int, or 0 if empty/invalid. The value has already
|
||||
// passed validate(), so a parse failure here is unreachable in normal flow.
|
||||
func (o *Options) Int(name string) int {
|
||||
n, _ := strconv.ParseInt(strings.TrimSpace(o.vals[name]), 10, 64)
|
||||
return n
|
||||
return int(n)
|
||||
}
|
||||
|
||||
// Float returns the value as a float64, or 0 if empty/invalid.
|
||||
|
||||
Reference in New Issue
Block a user