Skip to content

Commit

Permalink
Refactor subcommand handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlbyk committed Apr 8, 2012
1 parent 4b04981 commit 7172dd2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions GitTabExpansion.ps1
Expand Up @@ -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*" }
}

Expand Down Expand Up @@ -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']
}

Expand Down

0 comments on commit 7172dd2

Please sign in to comment.