Add redirecting for explicit python(3) commands

This commit is contained in:
Reinier Criel 2025-10-27 13:00:18 -07:00
parent f6381f5e91
commit 57bbb06f39
6 changed files with 143 additions and 5 deletions

View file

@ -94,3 +94,28 @@ function pip {
function pip3 {
Invoke-WrappedCommand "pip3" "aikido-pip3" $args
}
# `python -m pip`, `python -m pip3`.
function python {
param([Parameter(ValueFromRemainingArguments=$true)]$Args)
if ($Args.Length -ge 2 -and $Args[0] -eq '-m' -and $Args[1] -match '^pip(3)?$') {
if ($Args[1] -eq 'pip3') { Invoke-WrappedCommand 'pip3' 'aikido-pip3' $Args[2..($Args.Length-1)] }
else { Invoke-WrappedCommand 'pip' 'aikido-pip' $Args[2..($Args.Length-1)] }
}
else {
Invoke-RealCommand 'python' $Args
}
}
# `python3 -m pip`, `python3 -m pip3'.
function python3 {
param([Parameter(ValueFromRemainingArguments=$true)]$Args)
if ($Args.Length -ge 2 -and $Args[0] -eq '-m' -and $Args[1] -match '^pip(3)?$') {
if ($Args[1] -eq 'pip3') { Invoke-WrappedCommand 'pip3' 'aikido-pip3' $Args[2..($Args.Length-1)] }
else { Invoke-WrappedCommand 'pip' 'aikido-pip' $Args[2..($Args.Length-1)] }
}
else {
Invoke-RealCommand 'python3' $Args
}
}