mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: smarter if condition wrapping (#8201)
This commit is contained in:
@@ -221,13 +221,13 @@ fn (mut flag Flag) parse(args []string, with_abbrev bool) ?[]string {
|
||||
// matches returns `true` if first arg in `args` matches this flag.
|
||||
fn (mut flag Flag) matches(args []string, with_abbrev bool) bool {
|
||||
if with_abbrev {
|
||||
return (flag.name != '' && args[0] == '--$flag.name') ||
|
||||
(flag.name != '' && args[0].starts_with('--$flag.name=')) ||
|
||||
(flag.abbrev != '' && args[0] == '-$flag.abbrev') ||
|
||||
(flag.abbrev != '' && args[0].starts_with('-$flag.abbrev='))
|
||||
return (flag.name != '' && args[0] == '--$flag.name')
|
||||
|| (flag.name != '' && args[0].starts_with('--$flag.name='))
|
||||
|| (flag.abbrev != '' && args[0] == '-$flag.abbrev')
|
||||
|| (flag.abbrev != '' && args[0].starts_with('-$flag.abbrev='))
|
||||
} else {
|
||||
return (flag.name != '' && args[0] == '-$flag.name') ||
|
||||
(flag.name != '' && args[0].starts_with('-$flag.name='))
|
||||
return (flag.name != '' && args[0] == '-$flag.name')
|
||||
|| (flag.name != '' && args[0].starts_with('-$flag.name='))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -111,8 +111,8 @@ fn (cmd Command) help_message() string {
|
||||
}
|
||||
base_indent := ' '.repeat(base_indent_len)
|
||||
description_indent := ' '.repeat(name_len - flag_name.len)
|
||||
help += '$base_indent$flag_name$description_indent' + pretty_description(flag.description +
|
||||
required, base_indent_len + name_len) + '\n'
|
||||
help += '$base_indent$flag_name$description_indent' +
|
||||
pretty_description(flag.description + required, base_indent_len + name_len) + '\n'
|
||||
}
|
||||
}
|
||||
if cmd.commands.len > 0 {
|
||||
@@ -120,8 +120,8 @@ fn (cmd Command) help_message() string {
|
||||
for command in cmd.commands {
|
||||
base_indent := ' '.repeat(base_indent_len)
|
||||
description_indent := ' '.repeat(name_len - command.name.len)
|
||||
help += '$base_indent$command.name$description_indent' + pretty_description(command.description, name_len) +
|
||||
'\n'
|
||||
help += '$base_indent$command.name$description_indent' +
|
||||
pretty_description(command.description, name_len) + '\n'
|
||||
}
|
||||
}
|
||||
return help
|
||||
|
||||
Reference in New Issue
Block a user