feat(cli): version subcommand + --version flag; rename functional marker#58
Merged
Conversation
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.
46e23aa to
9de7b44
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
loseit version+loseit --versionBoth print the same payload:
tag-releaseCI job.--versionis eager — it short-circuits before any config/auth lookup, so it works on a bare clone with noLOSEIT_*env vars or token.loseit --output json version(ortoon) 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 fromversion.txt). There's a small fallback to readingversion.txtdirectly forpython -m lose_it.cliruns against an uninstalled source tree.requires_authmarker (replacesLOSEIT_RUN_FUNCTIONAL=1)@pytest.mark.requires_authmarker on every test undertests/functional/that touches the live API.tests/conftest.pyadds a--run-authpytest CLI flag and skipsrequires_authtests unless the flag is passed.tests/functional/test_*.pyfiles drop their per-file env-var_gate()autouse fixtures.pyproject.tomlmarker entry,.github/workflows/ci.ymlcommentary, and the README's contributing + testing sections all updated to reference--run-authinstead of the env var. CI's pytest invocation is unchanged —requires_authtests just self-skip without the flag.Tests
New
tests/conformance/test_version.py(4 tests, no network, no auth):versionsubcommand prints all required fields in text mode.--versionglobal flag prints the same payload.--output json versionemits the structured envelope.--versionworks with everyLOSEIT_*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 buildproduceslose_it-0.2.0.tar.gz+ wheel.uv run loseit versionanduv run loseit --versionprint correct text.uv run loseit --output json versionand--output toon versionemit structured payloads.version-checkjob seesv0.2.0as unreleased.v0.2.0appears on the repo after merge.