-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2363 from pypa/feature/repatch-shell-detection
Upgrade Click-Completion and apply Shellingham for shell detection
- Loading branch information
Showing
15 changed files
with
376 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import os | ||
|
||
from .environments import PIPENV_SHELL_EXPLICIT, PIPENV_SHELL | ||
from .vendor import shellingham | ||
|
||
|
||
class ShellDetectionFailure(shellingham.ShellDetectionFailure): | ||
pass | ||
|
||
|
||
def _build_info(value): | ||
return (os.path.splitext(os.path.basename(value))[0], value) | ||
|
||
|
||
def detect_info(): | ||
if PIPENV_SHELL_EXPLICIT: | ||
return _build_info(PIPENV_SHELL_EXPLICIT) | ||
try: | ||
return shellingham.detect_shell() | ||
except (shellingham.ShellDetectionFailure, TypeError): | ||
if PIPENV_SHELL: | ||
return _build_info(PIPENV_SHELL) | ||
raise ShellDetectionFailure |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
_{{prog_name}}_completion() { | ||
local IFS=$'\t' | ||
COMPREPLY=( $( env COMP_WORDS="${COMP_WORDS[*]}" \ | ||
COMP_CWORD=$COMP_CWORD \ | ||
{%- for k, v in extra_env.items() %} | ||
{{k}}={{v}} \ | ||
{%- endfor %} | ||
{{complete_var}}=complete-bash $1 ) ) | ||
return 0 | ||
} | ||
|
||
complete -F _{{prog_name}}_completion -o default {{prog_name}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
complete --command {{prog_name}} --arguments "(env {{complete_var}}=complete-fish COMMANDLINE=(commandline -cp){% for k, v in extra_env.items() %} {{k}}={{v}}{% endfor %} {{prog_name}})" -f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
if ((Test-Path Function:\TabExpansion) -and -not (Test-Path Function:\{{prog_name}}TabExpansionBackup)) { | ||
Rename-Item Function:\TabExpansion {{prog_name}}TabExpansionBackup | ||
} | ||
|
||
function TabExpansion($line, $lastWord) { | ||
$lastBlock = [regex]::Split($line, '[|;]')[-1].TrimStart() | ||
$aliases = @("{{prog_name}}") + @(Get-Alias | where { $_.Definition -eq "{{prog_name}}" } | select -Exp Name) | ||
$aliasPattern = "($($aliases -join '|'))" | ||
if($lastBlock -match "^$aliasPattern ") { | ||
$Env:{{complete_var}} = "complete-powershell" | ||
$Env:COMMANDLINE = "$lastBlock" | ||
{%- for k, v in extra_env.items() %} | ||
$Env:{{k}} = "{{v}}" | ||
{%- endfor %} | ||
({{prog_name}}) | ? {$_.trim() -ne "" } | ||
Remove-Item Env:{{complete_var}} | ||
Remove-Item Env:COMMANDLINE | ||
{%- for k in extra_env.keys() %} | ||
Remove-Item $Env:{{k}} | ||
{%- endfor %} | ||
} | ||
elseif (Test-Path Function:\{{prog_name}}TabExpansionBackup) { | ||
# Fall back on existing tab expansion | ||
{{prog_name}}TabExpansionBackup $line $lastWord | ||
} | ||
} |
Oops, something went wrong.