Skip to content

Instantly share code, notes, and snippets.

@dfinke
Created October 12, 2013 16:10
Show Gist options
  • Save dfinke/6951741 to your computer and use it in GitHub Desktop.
Save dfinke/6951741 to your computer and use it in GitHub Desktop.
Use PowerShell to extract Subversion commands and the parameters from help to a hash table
$svninfo = @{}
svn help |
?{$_ -match "^ "} |
%{($_.trim() -split " ")[0]} |
%{
$command = $_
if(!$svninfo.ContainsKey($command)) {
$svninfo.$command=@{SingleHyphen=@();DoubleHyphen=@()}
}
svn help $_ |
?{$_ -match "^\s+-"} |
%{
$_.Trim() | % {
$parameter = (($_ -split ":")[0] -split ' ')[0]
if($parameter.StartsWith("--")) {
$svninfo.$command.DoubleHyphen+=$parameter -replace '--', ''
} else {
$svninfo.$command.SingleHyphen+=$parameter -replace '-', ''
}
}
}
}
$svninfo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment