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 olink.__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 olink.__metadata__ import PROJECT_NAME
>>> PROJECT_NAME
'olink'

As a command-line tool#

Open the page you want for the current project by naming a target:

olink open origin     # Open the remote's homepage
olink open issues     # Open the issues page
olink open pypi       # Open the PyPI project page
olink url pypi        # Print the URL without opening it
olink list            # List targets available for the current project
olink list --all      # List every known target
olink interactive     # Launch the TUI (needs the ``tui`` extra)
olink --version       # Show the olink version

Every command accepts -d/--directory to point olink at a different project directory:

version and info accept the option for consistent invocation but ignore it because their output does not depend on a project.

olink open -d /path/to/project issues

open, url, list, version and info accept --json for scripts and agents. Stdout is then exactly one JSON document, errors included ({"error": {"type": ..., "message": ...}}), and failures exit with a distinct code per error type: 3 unknown target, 4 bad directory, 5 not a git repo, 6 no remote, 7 missing project metadata, 8 unsupported on this platform, 9 unknown git host.

olink url pypi --json
olink list --json

Or invoke it programmatically from Python:

examples/cli_usage.py#
"""CLI argument parsing."""

from __future__ import annotations

from olink.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#

Run olink interactive to launch the interactive terminal user interface (requires the tui extra — install with uv tool install 'olink[tui]'):

olink interactive