Skip to content

Clarifications to the command-line tools guide#2061

Open
anpol wants to merge 3 commits into
pypa:mainfrom
anpol:cli-tools-guide-clarify
Open

Clarifications to the command-line tools guide#2061
anpol wants to merge 3 commits into
pypa:mainfrom
anpol:cli-tools-guide-clarify

Conversation

@anpol
Copy link
Copy Markdown

@anpol anpol commented May 25, 2026

The original command-line tools tutorial mixed together three separate execution-related concepts:

  • the callable app object, which defines the Typer-based CLI interface;
  • the if __name__ == "__main__" execution guard, typically used for direct module execution;
  • the __main__.py package entry point, used by python -m greetings;

This PR cleanly separates these responsibilities by:

  • keeping CLI definition in cli.py,
  • exposing an explicit main() entry function,
  • and reducing __main__.py to a thin package launcher.

This is the series of commits, please review them in order.


📚 Documentation preview 📚: https://python-packaging-user-guide--2061.org.readthedocs.build/en/2061/

When describing a CLI command with `typer`, it might be more common to
use unqualified names, especially when you are defining many command
parameters and want to avoid repetitive typing.
@anpol anpol changed the title Clarifications for the command-line tools guide Clarifications to the command-line tools guide May 25, 2026
The intent of `greetings.cli` is likely to preconfigure the `app`
object, exportable for reuse by others.

Allowing `greetings.cli` to be runnable as a module didn't make much
sense, because the `greetings` module itself is already runnable.

Exporting the `main()` function and referencing it from the
`pyproject.toml` is likely more common and concise than relying on the
fact that the `app` object itself is callable.
@anpol anpol force-pushed the cli-tools-guide-clarify branch from 28d9150 to 2fba17b Compare May 27, 2026 06:55
Importing the `main()` function is likely more common and concise than
relying on the heavy-weight `app` object to be callable.
@anpol anpol force-pushed the cli-tools-guide-clarify branch from 2fba17b to 00978cc Compare May 27, 2026 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant