Skip to content

Commit

Permalink
Fixed parameter help parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
dodmi committed Dec 26, 2024
1 parent ea7f1a2 commit 4d393c1
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/GitHintTabExpansion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,15 @@ function Get-GITParameterHint {
{
switch -RegEx ($line) {
# -p, --param This is the parameter p
"^(-.), --([^\s\[]+)\s+([^<]*)$" {
# -p, --[no-]param This is the parameter p
"^(-.), --(?:\[no-\]){0,1}([^\s\[]+)\s+([^<]*)$" {
$helpTable.add($matches[1], @(($matches[1] +" ("+ $matches[2] +")"), $matches[3]))
$helpTable.add("--"+$matches[2], @(("--"+ $matches[2]), $matches[3]))
break
}
# --param This is the parameter p
"^--([^\s\[]+)\s+([^<]*)$" {
# --[no-]param This is the parameter p
"^--(?:\[no-\]){0,1}([^\s\[]+)\s+([^<]*)$" {
$helpTable.add("--"+$matches[1], @(("--"+ $matches[1]), $matches[2]))
break
}
Expand All @@ -99,13 +101,15 @@ function Get-GITParameterHint {
break
}
# -p, --param <file> This is the parameter p
"^(-.), --([^\s\[]+)\s(<[^>]*>)\s+(.*)$" {
# -p, --[no-]param <file> This is the parameter p
"^(-.), --(?:\[no-\]){0,1}([^\s\[]+)\s(<[^>]*>)\s+(.*)$" {
$helpTable.add($matches[1], @(($matches[1] +" ("+ $matches[2] +")"), ($matches[3]+" | "+$matches[4])))
$helpTable.add("--"+$matches[2], @(("--"+ $matches[2]), ($matches[3]+" | "+$matches[4])))
break
}
# --param <file> This is the parameter p
"^--([^\s\[]+)\s(<[^>]*>)\s+(.*)$" {
# --[no-]param <file> This is the parameter p
"^--(?:\[no-\]){0,1}([^\s\[]+)\s(<[^>]*>)\s+(.*)$" {
$helpTable.add("--"+$matches[1], @(("--"+ $matches[1]), ($matches[2]+" | "+$matches[3])))
break
}
Expand All @@ -115,13 +119,15 @@ function Get-GITParameterHint {
break
}
# -p, --param[=foo] This is the parameter p
"^(-.), --([^\s\[]+)(\[[^\]]*\])\s+(.*)$" {
# -p, --[no-]param[=foo] This is the parameter p
"^(-.), --(?:\[no-\]){0,1}([^\s\[]+)(\[[^\]]*\])\s+(.*)$" {
$helpTable.add($matches[1], @(($matches[1] +" ("+ $matches[2] +")"), ($matches[3]+" | "+$matches[4])))
$helpTable.add("--"+$matches[2], @(("--"+ $matches[2]), ($matches[3]+" | "+$matches[4])))
break
}
# --param[=foo] This is the parameter p
"^--([^\s\[]+)(\[[^\]]*\])\s+(.*)$" {
# --[no-]param[=foo] This is the parameter p
"^--(?:\[no-\]){0,1}([^\s\[]+)(\[[^\]]*\])\s+(.*)$" {
$helpTable.add("--"+$matches[1], @(("--"+ $matches[1]), ($matches[2]+" | "+$matches[3])))
break
}
Expand Down

0 comments on commit 4d393c1

Please sign in to comment.