Skip to content

Commit cb44dd9

Browse files
committed
Extract approved verbs to a variable
1 parent 76c79ef commit cb44dd9

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

PowerShell.sublime-syntax

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -210,26 +210,11 @@ contexts:
210210
- include: expressions
211211
212212
commands:
213-
# "Verb-Noun pattern:"
213+
# The "Verb-Noun" pattern
214214
- match: |-
215215
(?x:
216216
(?:[\w\\:-]*\\)? # Path stuff
217-
\b(?i:
218-
Add | Approve | Assert | Backup | Block | Build | Checkpoint # "Official" Verbs
219-
| Clear | Close | Compare | Complete | Compress | Confirm | Connect
220-
| Convert | ConvertFrom | ConvertTo | Copy | Debug | Deny | Deploy
221-
| Disable | Disconnect | Dismount | Edit | Enable | Enter | Exit
222-
| Expand | Export | Find | Format | Get | Grant | Group | Hide
223-
| Import | Initialize | Install | Invoke | Join | Limit | Lock
224-
| Measure | Merge | Mount | Move | New | Open | Optimize | Out | Ping
225-
| Pop | Protect | Publish | Push | Read | Receive | Redo | Register
226-
| Remove | Rename | Repair | Request | Reset | Resize | Resolve
227-
| Restart | Restore | Resume | Revoke | Save | Search | Select | Send
228-
| Set | Show | Skip | Split | Start | Step | Stop | Submit | Suspend
229-
| Switch | Sync | Test | Trace | Unblock | Undo | Uninstall | Unlock
230-
| Unprotect | Unpublish | Unregister | Update | Use | Wait | Watch
231-
| Write
232-
)
217+
{{command_verbs}} # Approved verbs
233218
\-\w+? # Any "noun"
234219
(?:\.(?i:exe|cmd|bat|ps1))?\b # More path stuff
235220
)
@@ -885,3 +870,31 @@ variables:
885870
)\b
886871
)
887872
var_scope_mod: (?i:global|local|private|script|using|workflow)
873+
874+
# The "Approved Verbs" list
875+
# https://learn.microsoft.com/en-us/powershell/scripting/developer/cmdlet/approved-verbs-for-windows-powershell-commands
876+
command_verbs: |-
877+
\b(?xi:
878+
# Common verbs
879+
Add | Clear | Close | Copy | Enter | Exit | Find | Format | Get | Hide
880+
| Join | Lock | Move | New | Open | Optimize | Pop | Push | Redo | Remove
881+
| Rename | Reset | Resize | Search | Select | Set | Show | Skip | Split
882+
| Step | Switch | Undo | Unlock | Watch
883+
# Communications verbs
884+
| Connect | Disconnect | Read | Receive | Send | Write
885+
# Data verbs
886+
| Backup | Checkpoint | Compare | Compress | Convert | ConvertFrom
887+
| ConvertTo | Dismount | Edit | Expand | Export | Group | Import
888+
| Initialize | Limit | Merge | Mount | Out | Publish | Restore | Save
889+
| Sync | Unpublish | Update
890+
# Diagnostic verbs
891+
| Debug | Measure | Ping | Repair | Resolve | Test | Trace
892+
# Lifecycle verbs
893+
| Approve | Assert | Build | Complete | Confirm | Deny | Deploy | Disable
894+
| Enable | Install | Invoke | Register | Request | Restart | Resume | Start
895+
| Stop | Submit | Suspend | Uninstall | Unregister | Wait
896+
# Security verbs
897+
| Block | Grant | Protect | Revoke | Unblock | Unprotect
898+
# Other verbs
899+
| Use
900+
)\b

0 commit comments

Comments
 (0)