Skip to content

feat(cli): version subcommand + --version flag; rename functional marker#58

Merged
phitoduck merged 2 commits into
mainfrom
feat-version-cli
Jun 12, 2026
Merged

feat(cli): version subcommand + --version flag; rename functional marker#58
phitoduck merged 2 commits into
mainfrom
feat-version-cli

Conversation

@phitoduck

Copy link
Copy Markdown
Owner

Summary

loseit version + loseit --version

Both print the same payload:

loseit 0.2.0
Release: https://github.com/phitoduck/lose-it/releases/tag/v0.2.0
License: MIT

This project is unaffiliated with Lose It! / FitNow, Inc.
Thank you for using it!
  • Release URL uses the v-prefixed tag pushed by the tag-release CI job.
  • License (MIT) read from a single constant.
  • --version is eager — it short-circuits before any config/auth lookup, so it works on a bare clone with no LOSEIT_* env vars or token.
  • loseit --output json version (or toon) emits the same fields as a structured envelope.

The CLI reads the version via importlib.metadata.version("lose-it") so the displayed version always matches the installed dist (which hatchling populates from version.txt). There's a small fallback to reading version.txt directly for python -m lose_it.cli runs against an uninstalled source tree.

requires_auth marker (replaces LOSEIT_RUN_FUNCTIONAL=1)

  • New @pytest.mark.requires_auth marker on every test under tests/functional/ that touches the live API.
  • tests/conftest.py adds a --run-auth pytest CLI flag and skips requires_auth tests unless the flag is passed.
  • All four tests/functional/test_*.py files drop their per-file env-var _gate() autouse fixtures.
  • pyproject.toml marker entry, .github/workflows/ci.yml commentary, and the README's contributing + testing sections all updated to reference --run-auth instead of the env var. CI's pytest invocation is unchanged — requires_auth tests just self-skip without the flag.

Tests

New tests/conformance/test_version.py (4 tests, no network, no auth):

  • version subcommand prints all required fields in text mode.
  • --version global flag prints the same payload.
  • --output json version emits the structured envelope.
  • --version works with every LOSEIT_* env var unset.

Version bumped 0.1.0 → 0.2.0 (minor — new CLI surface, per AGENTS.md).

Test plan

  • uv run pytest --no-cov -q → 165 passed, 5 skipped (requires_auth).
  • uv run pytest --run-auth --collect-only → all 170 tests collected.
  • uv run ruff check . + uv run ruff format --check . clean.
  • uv build produces lose_it-0.2.0.tar.gz + wheel.
  • uv run loseit version and uv run loseit --version print correct text.
  • uv run loseit --output json version and --output toon version emit structured payloads.
  • CI version-check job sees v0.2.0 as unreleased.
  • Tag v0.2.0 appears on the repo after merge.

@phitoduck phitoduck closed this Jun 12, 2026
@phitoduck phitoduck reopened this Jun 12, 2026
Adds:

- ``loseit version`` subcommand and ``loseit --version`` global flag. Both
  print the semver, v-prefixed release URL on GitHub, ``License: MIT``,
  the "unaffiliated with Lose It! / FitNow, Inc." disclaimer, and a thanks
  blurb. ``--version`` is eager so it short-circuits before config/auth
  resolution. ``loseit --output json|toon version`` emits the same payload
  as a structured envelope.
- ``tests/conformance/test_version.py`` covers text + structured output
  and verifies ``--version`` works with no LOSEIT_* env vars set.

Replaces the ``LOSEIT_RUN_FUNCTIONAL=1`` env-var gate with a
``@pytest.mark.requires_auth`` marker. Tests with this marker are skipped
unless ``pytest --run-auth`` is passed (wired via ``pytest_addoption`` +
``pytest_collection_modifyitems`` in ``tests/conftest.py``). Removes the
per-file ``_gate()`` autouse fixtures from ``tests/functional/*.py``.
Updates the marker entry in ``pyproject.toml``, the CI workflow's
commentary, and the README's contributing + testing sections to reflect
the new flag.

Bumps version.txt to 0.2.0 (minor — new ``version`` command).
Per review feedback: the custom ``--run-auth`` flag + ``pytest_collection_modifyitems``
was overbuilt. Standard pytest idiom is enough:

- ``pyproject.toml`` now sets ``addopts = ["-m", "not requires_auth"]``, so a
  bare ``pytest`` excludes the live-API suite automatically (same default
  behaviour as before, fewer moving parts).
- ``pytest -m requires_auth`` runs only the live-API suite.
- ``pytest -m "requires_auth or not requires_auth"`` runs everything.

Removes the ``pytest_addoption`` / ``pytest_collection_modifyitems`` hooks
from ``tests/conftest.py`` and updates the README + CI commentary.
@phitoduck phitoduck force-pushed the feat-version-cli branch 2 times, most recently from 46e23aa to 9de7b44 Compare June 12, 2026 20:47
@phitoduck phitoduck merged commit 1b3086c into main Jun 12, 2026
4 checks passed
@phitoduck phitoduck deleted the feat-version-cli branch June 12, 2026 20:48
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