Usage#
As a library#
Look up the installed distribution version:
examples/version_lookup.py#
"""Look up the version of the installed distribution."""
from importlib.metadata import version
from pun.__metadata__ import PROJECT_NAME
def version_lookup() -> str:
"""Return the installed distribution version for this project.
Returns:
str: The installed distribution version.
"""
return version(PROJECT_NAME)
For short interactive snippets embedded in prose, the docs-doctest task
executes >>> blocks too:
>>> from pun.__metadata__ import PROJECT_NAME
>>> PROJECT_NAME
'pun'
As a command-line tool#
To use pun as a command-line tool:
pun version
pun info
Or invoke it programmatically from Python:
examples/cli_usage.py#
"""CLI argument parsing."""
from __future__ import annotations
from pun.cli.app import app
def cli_app_name() -> str:
"""Return the registered CLI application name.
Returns:
str: The Typer application name.
"""
return app.info.name or ""
As a TUI#
To launch the terminal user interface:
pun interactive
Retrieve the info message without starting the TUI:
examples/tui_usage.py#
"""Headless TUI information retrieval."""
from __future__ import annotations
from pun.tui.app import build_info_message
def tui_info() -> str:
"""Return the info message without starting the TUI.
Returns:
str: A multi-line project information summary.
"""
return build_info_message()