Skip to content

Commit 6cde0d9

Browse files
JonZeollaclaude
andcommitted
feat: add --version and --help to template entrypoint
Add argparse to main.py so the generated project supports --version (from __init__.__version__) and --help out of the box. Update Docker verify to test both flags directly via the container entrypoint. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 196a9b7 commit 6cde0d9

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

  • .github/workflows
  • {{cookiecutter.project_name|replace(" ", "")}}/src

.github/workflows/ci.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,8 @@ jobs:
236236
- name: Verify Docker image
237237
shell: bash
238238
run: |
239-
# Verify the Python runtime is functional
240-
docker run --rm --entrypoint python3 zenable-io/replace-me:latest --version
241-
# Verify the project module is importable and reports its version
242-
docker run --rm --entrypoint python3 zenable-io/replace-me:latest \
243-
-c "from replace_me import __version__; print(__version__)"
239+
docker run --rm zenable-io/replace-me:latest --version
240+
docker run --rm zenable-io/replace-me:latest --help
244241
- name: Verify zenable CLI
245242
shell: bash
246243
run: |

{{cookiecutter.project_name|replace(" ", "")}}/src/main.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@
33
{{ cookiecutter.project_name }} script entrypoint
44
"""
55

6-
from {{ cookiecutter.project_slug }} import config
6+
import argparse
7+
8+
from {{ cookiecutter.project_slug }} import __version__, config
79

810

911
def main():
1012
"""Main entry point for the application."""
13+
parser = argparse.ArgumentParser(description="{{ cookiecutter.project_short_description | replace('"', '\\"') | replace("'", "\\\\'") }}")
14+
parser.add_argument("--version", action="version", version=f"%(prog)s {__version__}")
15+
parser.parse_args()
16+
1117
log = config.setup_logging()
1218
log.debug("Logging initialized with level: %s", log.level)
1319

0 commit comments

Comments
 (0)