bumpy-spring-43024
05/25/2023, 9:17 AMpex_binary(
name="cli_binary",
script="script",
dependencies=[
":cli",
...
],
)
And here's the associated python_distribution:
python_distribution(
name='cli',
dependencies=["!//:root#cli"],
provides=setup_py(
name='cli',
version='0.1.0',
),
entry_points={
"console_scripts": {
"script": "cli.__main__:main"
}
},
)
• For reference: Click docs on shell completionenough-analyst-54434
05/25/2023, 2:59 PMexecution_mode="venv"
for your pex_binary
?: https://www.pantsbuild.org/docs/reference-pex_binary#codeexecution_modecodeenough-analyst-54434
05/25/2023, 3:00 PMbumpy-spring-43024
05/25/2023, 3:13 PMenough-analyst-54434
05/25/2023, 4:23 PMjsirois@Gill-Windows:~/support/pants/JanBar $ pex hatch -c hatch -- new --cli example
example
├── src
│ └── example
│ ├── cli
│ │ └── __init__.py
│ ├── __about__.py
│ ├── __init__.py
│ └── __main__.py
├── tests
│ └── __init__.py
├── LICENSE.txt
├── README.md
└── pyproject.toml
jsirois@Gill-Windows:~/support/pants/JanBar $ pex example/ -c example --venv -o ~/bin/example
jsirois@Gill-Windows:~/support/pants/JanBar $ _EXAMPLE_COMPLETE=bash_source example
_example_completion() {
local IFS=$'\n'
local response
response=$(env COMP_WORDS="${COMP_WORDS[*]}" COMP_CWORD=$COMP_CWORD _EXAMPLE_COMPLETE=bash_complete $1)
for completion in $response; do
IFS=',' read type value <<< "$completion"
if [[ $type == 'dir' ]]; then
COMPREPLY=()
compopt -o dirnames
elif [[ $type == 'file' ]]; then
COMPREPLY=()
compopt -o default
elif [[ $type == 'plain' ]]; then
COMPREPLY+=($value)
fi
done
return 0
}
_example_completion_setup() {
complete -o nosort -F _example_completion example
}
_example_completion_setup;
bumpy-spring-43024
06/01/2023, 9:48 AM