cli: remove flags.get_*_or variants (#8102)
parent
512f62b7a1
commit
d16721e5b8
|
@ -36,11 +36,6 @@ pub fn (flags []Flag) get_bool(name string) ?bool {
|
||||||
return flag.get_bool()
|
return flag.get_bool()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (flags []Flag) get_bool_or(name string, or_value bool) bool {
|
|
||||||
value := flags.get_bool(name) or { return or_value }
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn (flag Flag) get_int() ?int {
|
pub fn (flag Flag) get_int() ?int {
|
||||||
if flag.flag != .int {
|
if flag.flag != .int {
|
||||||
return error('$flag.name: Invalid flag type `$flag.flag`, expected `int`')
|
return error('$flag.name: Invalid flag type `$flag.flag`, expected `int`')
|
||||||
|
@ -53,11 +48,6 @@ pub fn (flags []Flag) get_int(name string) ?int {
|
||||||
return flag.get_int()
|
return flag.get_int()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (flags []Flag) get_int_or(name string, or_value int) int {
|
|
||||||
value := flags.get_int(name) or { return or_value }
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn (flag Flag) get_float() ?f64 {
|
pub fn (flag Flag) get_float() ?f64 {
|
||||||
if flag.flag != .float {
|
if flag.flag != .float {
|
||||||
return error('$flag.name: Invalid flag type `$flag.flag`, expected `float`')
|
return error('$flag.name: Invalid flag type `$flag.flag`, expected `float`')
|
||||||
|
@ -70,11 +60,6 @@ pub fn (flags []Flag) get_float(name string) ?f64 {
|
||||||
return flag.get_float()
|
return flag.get_float()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (flags []Flag) get_float_or(name string, or_value f64) f64 {
|
|
||||||
value := flags.get_float(name) or { return or_value }
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn (flag Flag) get_string() ?string {
|
pub fn (flag Flag) get_string() ?string {
|
||||||
if flag.flag != .string {
|
if flag.flag != .string {
|
||||||
return error('$flag.name: Invalid flag type `$flag.flag`, expected `string`')
|
return error('$flag.name: Invalid flag type `$flag.flag`, expected `string`')
|
||||||
|
@ -87,11 +72,6 @@ pub fn (flags []Flag) get_string(name string) ?string {
|
||||||
return flag.get_string()
|
return flag.get_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (flags []Flag) get_string_or(name string, or_value string) string {
|
|
||||||
value := flags.get_string(name) or { return or_value }
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
|
|
||||||
// parse flag value from arguments and return arguments with all consumed element removed
|
// parse flag value from arguments and return arguments with all consumed element removed
|
||||||
fn (mut flag Flag) parse(args []string, with_abbrev bool) ?[]string {
|
fn (mut flag Flag) parse(args []string, with_abbrev bool) ?[]string {
|
||||||
if flag.matches(args, with_abbrev) {
|
if flag.matches(args, with_abbrev) {
|
||||||
|
|
Loading…
Reference in New Issue