Skip to content

Commit

Permalink
Argparser edge case for value options which are a prefix of flags
Browse files Browse the repository at this point in the history
  • Loading branch information
macneale4 committed Sep 15, 2024
1 parent b42eee3 commit b5bf8b9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
7 changes: 4 additions & 3 deletions go/libraries/utils/argparser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,10 @@ func (ap *ArgParser) matchModalOptions(arg string) (matches []*Option, rest stri

// stop if we see a value option
for _, vo := range ap.sortedValueOptions() {
lv := len(vo)
isValOpt := len(rest) >= lv && rest[:lv] == vo
if isValOpt {
if rest == vo {
return matches, rest
}
if strings.HasPrefix(rest, vo+"=") {
return matches, rest
}
}
Expand Down
12 changes: 12 additions & 0 deletions integration-tests/bats/diff.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1811,3 +1811,15 @@ SQL
[ $status -eq 1 ]
[[ $output =~ "invalid Arguments" ]] || false
}

@test "diff: diff --reverse" {
run dolt diff -R
[ $status -eq 0 ]
[[ $output =~ "diff --dolt a/test b/test" ]] || false
[[ $output =~ "deleted table" ]] || false

run dolt diff --reverse
[ $status -eq 0 ]
[[ $output =~ "diff --dolt a/test b/test" ]] || false
[[ $output =~ "deleted table" ]] || false
}

0 comments on commit b5bf8b9

Please sign in to comment.