Skip to content

Commit

Permalink
fix(entrypoint): use a sh-compatible function syntax for usage
Browse files Browse the repository at this point in the history
  • Loading branch information
noirbizarre committed Dec 15, 2023
1 parent ad7f265 commit a372c63
Show file tree
Hide file tree
Showing 23 changed files with 47 additions and 47 deletions.
6 changes: 3 additions & 3 deletions src/pdm_dockerize/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ def python_env() -> str:
def usage(project: Project, runner: TaskRunner) -> str:
"""Render the entrypoint usage/help"""
out = io.StringIO()
out.write("function usage() {\n")
out.write("usage() {\n")
out.write(f'{INDENT}echo "Available commands"\n')
out.write(f'{INDENT}echo -e "==================\\n"\n')
out.write(f'{INDENT}echo "=================="\n')

for script in select_scripts(project):
task = runner.get_task(script)
if task is None:
continue
if task.kind == "cmd" and isinstance(task.args, list):
out.write(f"{INDENT}echo \"{script}: {' '.join(task.args)}\"\n")
out.write(f'{INDENT}echo "{script}: {" ".join(task.args)}"\n')
else:
out.write(f'{INDENT}echo "{script}: {task.short_description}"\n')
out.write("}\n")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
export PYTHONPATH=./lib
export PATH=./bin:$PATH

function usage() {
usage() {
echo "Available commands"
echo -e "==================\n"
echo "=================="
}

case ${1} in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
export PYTHONPATH=./lib
export PATH=./bin:$PATH

function usage() {
usage() {
echo "Available commands"
echo -e "==================\n"
echo "=================="
echo "test:something: pytest something"
echo "ns:task2: ns:task2"
echo "ns:task3: ns:task3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
export PYTHONPATH=./lib
export PATH=./bin:$PATH

function usage() {
usage() {
echo "Available commands"
echo -e "==================\n"
echo "=================="
echo "test: pytest"
echo "test:something: pytest something"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
export PYTHONPATH=./lib
export PATH=./bin:$PATH

function usage() {
usage() {
echo "Available commands"
echo -e "==================\n"
echo "=================="
echo "test: pytest"
echo "test:something: pytest something"
echo "ns:task1: ns:task1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
export PYTHONPATH=./lib
export PATH=./bin:$PATH

function usage() {
usage() {
echo "Available commands"
echo -e "==================\n"
echo "=================="
echo "test: pytest"
echo "ns:task1: ns:task1"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
export PYTHONPATH=./lib
export PATH=./bin:$PATH

function usage() {
usage() {
echo "Available commands"
echo -e "==================\n"
echo "=================="
echo "ns:task2: ns:task2"
echo "ns:task3: ns:task3"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
export PYTHONPATH=./lib
export PATH=./bin:$PATH

function usage() {
usage() {
echo "Available commands"
echo -e "==================\n"
echo "=================="
}

case ${1} in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
export PYTHONPATH=./lib
export PATH=./bin:$PATH

function usage() {
usage() {
echo "Available commands"
echo -e "==================\n"
echo "=================="
echo "test: my.app:main('dev', key='value')"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
export PYTHONPATH=./lib
export PATH=./bin:$PATH

function usage() {
usage() {
echo "Available commands"
echo -e "==================\n"
echo "=================="
echo "test: my.app:main"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
export PYTHONPATH=./lib
export PATH=./bin:$PATH

function usage() {
usage() {
echo "Available commands"
echo -e "==================\n"
echo "=================="
echo "test: pytest"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
export PYTHONPATH=./lib
export PATH=./bin:$PATH

function usage() {
usage() {
echo "Available commands"
echo -e "==================\n"
echo "=================="
echo "test: pytest --with --params"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
export PYTHONPATH=./lib
export PATH=./bin:$PATH

function usage() {
usage() {
echo "Available commands"
echo -e "==================\n"
echo "=================="
echo "test: pytest"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
export PYTHONPATH=./lib
export PATH=./bin:$PATH

function usage() {
usage() {
echo "Available commands"
echo -e "==================\n"
echo "=================="
echo "test: first ➤ second"
}

Expand Down
4 changes: 2 additions & 2 deletions tests/__snapshots__/test_entrypoint/test_serilization[env].sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
export PYTHONPATH=./lib
export PATH=./bin:$PATH

function usage() {
usage() {
echo "Available commands"
echo -e "==================\n"
echo "=================="
echo "test: pytest"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
export PYTHONPATH=./lib
export PATH=./bin:$PATH

function usage() {
usage() {
echo "Available commands"
echo -e "==================\n"
echo "=================="
echo "test: pytest"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
export PYTHONPATH=./lib
export PATH=./bin:$PATH

function usage() {
usage() {
echo "Available commands"
echo -e "==================\n"
echo "=================="
echo "test: pytest"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
export PYTHONPATH=./lib
export PATH=./bin:$PATH

function usage() {
usage() {
echo "Available commands"
echo -e "==================\n"
echo "=================="
echo "test: pytest"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
export PYTHONPATH=./lib
export PATH=./bin:$PATH

function usage() {
usage() {
echo "Available commands"
echo -e "==================\n"
echo "=================="
echo "test: pytest"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
export PYTHONPATH=./lib
export PATH=./bin:$PATH

function usage() {
usage() {
echo "Available commands"
echo -e "==================\n"
echo "=================="
}

case ${1} in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
export PYTHONPATH=./lib
export PATH=./bin:$PATH

function usage() {
usage() {
echo "Available commands"
echo -e "==================\n"
echo "=================="
echo "test: pytest"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
export PYTHONPATH=./lib
export PATH=./bin:$PATH

function usage() {
usage() {
echo "Available commands"
echo -e "==================\n"
echo "=================="
echo "test: pytest"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
export PYTHONPATH=./lib
export PATH=./bin:$PATH

function usage() {
usage() {
echo "Available commands"
echo -e "==================\n"
echo "=================="
echo "test: pytest"
}

Expand Down

0 comments on commit a372c63

Please sign in to comment.