Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed May 1, 2024
1 parent 0778ed8 commit e2f3e93
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions vlib/cli/flag.v
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,13 @@ pub fn (mut flag Flag) parse(args []string, posix_mode bool) ![]string {
// matches returns `true` if first arg in `args` matches this flag.
fn (mut flag Flag) matches(arg string, posix_mode bool) bool {
prefix := if posix_mode { '--' } else { '-' }
return (flag.name != '' && arg.starts_with(prefix + flag.name))
|| (flag.abbrev != '' && arg.starts_with('-' + flag.abbrev))
return if flag.name != '' {
arg == '${prefix}${flag.name}' || arg.starts_with('-${flag.name}=')
} else if flag.abbrev != '' {
arg == '${prefix}${flag.abbrev}' || arg.starts_with('$-${flag.abbrev}=')
} else {
false
}
}

fn (mut flag Flag) parse_raw(args []string) ![]string {
Expand Down

0 comments on commit e2f3e93

Please sign in to comment.