Skip to content

Repository files navigation

cli-template

A Python CLI template that has two roles in one repo:

  • cli_foundation: reusable CLI/runtime plumbing
  • cli_template: generator for new projects

What is included

  • src/cli_foundation/ with reusable CLI bootstrap, config, logging, checks, and the shared config command
  • src/cli_template/ with the template app and the init generator command
  • dynamic command discovery from command packages
  • global --version and --verbose flags
  • an init command that creates a new thin CLI project
  • tests for both the shared runtime behavior and generator behavior
  • Makefile targets for install, format, lint, typecheck, and test

Quick start

Create a new CLI project:

make install
.venv/bin/cli-template
.venv/bin/cli-template init /tmp/my-new-cli  .                      # Name derived from path
.venv/bin/cli-template init /tmp/my-new-cli --name "Different name" # Or be explicit

# Reinitialize an existing clean git repository destination
.venv/bin/cli-template init /tmp/existing-project --reinitialize

# Bypass clean-repo reinitialize safeguards explicitly
.venv/bin/cli-template init /tmp/existing-project --reinitialize --force

Generated projects now stay thin:

  • app-specific code is generated into the new project
  • shared runtime code is not copied into the new project
  • the generated project depends on this package for shared CLI behavior

Project layout

src/
  cli_foundation/
    cli.py
    config.py
    logging.py
    checks/
    commands/
  cli_template/
    cli.py
    project_init.py
    commands/
    templates/
tests/

How to use the split

  • Put reusable CLI/runtime behavior in cli_foundation.
  • Keep project generation and init behavior in cli_template.
  • Let generated apps own only app-specific commands and business logic.

Current packaging note

The reusable import package is cli_foundation, while the generated-project dependency currently points at the distribution published from this repo. This is mostly for one-dev convenience, this can be split/renamed in the future if necessary.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages