Browse files

Refactor subcommand handling

  • Loading branch information...
1 parent 4b04981 commit 7172dd220ec5eb09cece21368cfc7c50796095f2 @dahlbyk committed Apr 8, 2012
Showing with 7 additions and 7 deletions.
  1. +7 −7 GitTabExpansion.ps1
View
14 GitTabExpansion.ps1
@@ -5,15 +5,15 @@ $global:GitTabSettings = New-Object PSObject -Property @{
AllCommands = $false
}
-$global:ops = @{
- reflog = 'expire','delete','show'
- remote = 'add','rename','rm','set-head','show','prune','update'
- stash = 'list','show','drop','pop','apply','branch','save','clear','create'
- svn = 'init', 'fetch', 'clone', 'rebase', 'dcommit', 'branch', 'tag', 'log', 'blame', 'find-rev', 'set-tree', 'create-ignore', 'show-ignore', 'mkdirs', 'commit-diff', 'info', 'proplist', 'propget', 'show-externals', 'gc', 'reset'
+$subcommands = @{
+ reflog = 'expire delete show'
+ remote = 'add rename rm set-head show prune update'
+ stash = 'list show drop pop apply branch save clear create'
+ svn = 'init fetch clone rebase dcommit branch tag log blame find-rev set-tree create-ignore show-ignore mkdirs commit-diff info proplist propget show-externals gc reset'
}
function script:gitCmdOperations($command, $filter) {
- $ops.$command |
+ $subcommands.$command -split ' ' |
where { $_ -like "$filter*" }
}
@@ -121,7 +121,7 @@ function GitTabExpansion($lastBlock) {
# Handles git remote <op>
# Handles git stash <op>
# Handles git svn <op>
- "^(?<cmd>reflog|remote|stash|svn)\s+(?<op>\S*)$" {
+ "^(?<cmd>$($subcommands.Keys -join '|'))\s+(?<op>\S*)$" {
gitCmdOperations $matches['cmd'] $matches['op']
}

0 comments on commit 7172dd2

Please sign in to comment.