-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRun-StackdumpCommand.ps1
31 lines (26 loc) · 2.15 KB
/
Run-StackdumpCommand.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<#
.SYNOPSIS
Executes a Stackdump management command.
.DESCRIPTION
Executes the Stackdump management command specified using the -Command
parameter (or implicitly via the first positional parameter). All
remaining arguments are passed to the management command.
This cmdlet uses the Start-Python cmdlet to execute the commands, so Python
needs to be able to be located for this cmdlet to work.
Use the List-StackdumpCommands cmdlet to see the possible commands.
.EXAMPLE
Run-StackdumpCommand download_site_info
#>
param(
[Parameter(Mandatory=$true, Position=1)][string]$Command,
[Parameter(ValueFromRemainingArguments=$true)][String[]]$CommandArgs
)
$ScriptDir = Split-Path $MyInvocation.MyCommand.Path
$CommandsDir = Join-Path $ScriptDir 'python\src\stackdump\commands'
$CommandPath = Join-Path $CommandsDir "$Command.py"
if (Test-Path $CommandPath) {
& "$ScriptDir\Start-Python.ps1" $CommandPath @CommandArgs
}
else {
Write-Error "The command '$Command' could not be found. Use List-StackdumpCommands to see a list of valid commands."
}