Skip to content

Commit 4d393c1

Browse files
committed
Fixed parameter help parsing
1 parent ea7f1a2 commit 4d393c1

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/GitHintTabExpansion.ps1

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,15 @@ function Get-GITParameterHint {
8383
{
8484
switch -RegEx ($line) {
8585
# -p, --param This is the parameter p
86-
"^(-.), --([^\s\[]+)\s+([^<]*)$" {
86+
# -p, --[no-]param This is the parameter p
87+
"^(-.), --(?:\[no-\]){0,1}([^\s\[]+)\s+([^<]*)$" {
8788
$helpTable.add($matches[1], @(($matches[1] +" ("+ $matches[2] +")"), $matches[3]))
8889
$helpTable.add("--"+$matches[2], @(("--"+ $matches[2]), $matches[3]))
8990
break
9091
}
9192
# --param This is the parameter p
92-
"^--([^\s\[]+)\s+([^<]*)$" {
93+
# --[no-]param This is the parameter p
94+
"^--(?:\[no-\]){0,1}([^\s\[]+)\s+([^<]*)$" {
9395
$helpTable.add("--"+$matches[1], @(("--"+ $matches[1]), $matches[2]))
9496
break
9597
}
@@ -99,13 +101,15 @@ function Get-GITParameterHint {
99101
break
100102
}
101103
# -p, --param <file> This is the parameter p
102-
"^(-.), --([^\s\[]+)\s(<[^>]*>)\s+(.*)$" {
104+
# -p, --[no-]param <file> This is the parameter p
105+
"^(-.), --(?:\[no-\]){0,1}([^\s\[]+)\s(<[^>]*>)\s+(.*)$" {
103106
$helpTable.add($matches[1], @(($matches[1] +" ("+ $matches[2] +")"), ($matches[3]+" | "+$matches[4])))
104107
$helpTable.add("--"+$matches[2], @(("--"+ $matches[2]), ($matches[3]+" | "+$matches[4])))
105108
break
106109
}
107110
# --param <file> This is the parameter p
108-
"^--([^\s\[]+)\s(<[^>]*>)\s+(.*)$" {
111+
# --[no-]param <file> This is the parameter p
112+
"^--(?:\[no-\]){0,1}([^\s\[]+)\s(<[^>]*>)\s+(.*)$" {
109113
$helpTable.add("--"+$matches[1], @(("--"+ $matches[1]), ($matches[2]+" | "+$matches[3])))
110114
break
111115
}
@@ -115,13 +119,15 @@ function Get-GITParameterHint {
115119
break
116120
}
117121
# -p, --param[=foo] This is the parameter p
118-
"^(-.), --([^\s\[]+)(\[[^\]]*\])\s+(.*)$" {
122+
# -p, --[no-]param[=foo] This is the parameter p
123+
"^(-.), --(?:\[no-\]){0,1}([^\s\[]+)(\[[^\]]*\])\s+(.*)$" {
119124
$helpTable.add($matches[1], @(($matches[1] +" ("+ $matches[2] +")"), ($matches[3]+" | "+$matches[4])))
120125
$helpTable.add("--"+$matches[2], @(("--"+ $matches[2]), ($matches[3]+" | "+$matches[4])))
121126
break
122127
}
123128
# --param[=foo] This is the parameter p
124-
"^--([^\s\[]+)(\[[^\]]*\])\s+(.*)$" {
129+
# --[no-]param[=foo] This is the parameter p
130+
"^--(?:\[no-\]){0,1}([^\s\[]+)(\[[^\]]*\])\s+(.*)$" {
125131
$helpTable.add("--"+$matches[1], @(("--"+ $matches[1]), ($matches[2]+" | "+$matches[3])))
126132
break
127133
}

0 commit comments

Comments
 (0)