Contributing
Authenticating the Lumos CLI
Contributing to Lumos CLI
Thank you for your interest in contributing to the Lumos CLI! This document provides guidelines and instructions for contributors and maintainers.
Reporting issues
Please report issues here or contact Lumos directly.
Development
Prerequisites
- Python 3.10.6 or higher
- uv (recommended) or pip
Installation
- Clone the repository:
git clone https://github.com/teamlumos/lumos-cli.git cd lumos-cli - Install dependencies with uv:
uv sync --group dev --group docs - Set up pre-commit hooks:
uv run pre-commit install
Running the CLI Locally
Create an alias for development:
alias lumosdev='uv run python -m lumos'Or run directly:
uv run python -m lumos --helpProject Structure
lumos-cli/
βββ src/lumos/ # Main source code
β βββ __init__.py
β βββ __main__.py # Entry point for `python -m lumos`
β βββ cli.py # Main CLI group and core commands
β βββ common/ # Shared utilities
β β βββ client.py # API client
β β βββ client_helpers.py
β β βββ helpers.py # Authentication helpers
β β βββ keyhelpers.py # Credential storage
β β βββ logging.py # Debug logging
β β βββ models.py # Pydantic models
β βββ list_collections/ # `lumos list` subcommands
β β βββ cli.py
β βββ request/ # `lumos request` subcommands
β βββ cli.py
βββ tests/ # Test files
βββ docs/ # Sphinx documentation (auto-generated)
βββ sample-scripts/ # Example scripts for users
βββ pyproject.toml # Project configuration
βββ .releaserc.yaml # Semantic release configuration
βββ .github/workflows/ # CI/CD workflowsDevelopment Workflow
Creating a Branch
- Create a feature branch from
main:git checkout -b feat/your-feature-name - Follow Angular commit conventions:
feat:- New featuresfix:- Bug fixesdocs:- Documentation changesrefactor:- Code refactoringtest:- Adding or updating testschore:- Maintenance tasks
Adding a New Command
- Create a new module in the appropriate directory (e.g.,
src/lumos/your_feature/cli.py) - Define your click command:
from click_extra import command, option from lumos.common.helpers import authenticate @command("your-command", help="Description of your command") @option("--flag", is_flag=True, help="Option description") @authenticate def your_command(flag: bool) -> None: """Your command implementation.""" pass - Register the command in
src/lumos/cli.py:def register_subcommands(): from lumos.your_feature.cli import your_command cli.add_command(your_command) - Add tests in
tests/ - Update documentation in
docs/
Code Style
We use ruff for linting and formatting, and basedpyright for type checking.
Running Linters
# Run all checks
uv run ruff check .
uv run ruff format --check .
uv run basedpyright
# Auto-fix issues
uv run ruff check --fix .
uv run ruff format .Style Guidelines
- Maximum line length: 120 characters
- Use double quotes for strings
- Use type hints for all function parameters and return values
- Follow PEP 8 naming conventions
Testing
Running Tests
uv run pytestRunning Tests with Coverage
uv run pytest --cov=lumos --cov-report=htmlWriting Tests
- Place test files in the
tests/directory - Name test files with
_test.pysuffix - Use descriptive test function names:
test_command_does_expected_behavior
Documentation
Documentation is built using Sphinx with MyST Markdown and click-extraβs Sphinx extension for interactive CLI documentation with ANSI color support.
Building Documentation Locally
# Install docs dependencies
uv sync --group docs
# Build both HTML and Markdown, copy markdown to docs/
make -C docs docs
# Or build individually:
make -C docs html # HTML only
make -C docs markdown # Markdown only
# View the HTML docs
open docs/src/_build/html/index.htmlDocumentation Structure
Source files (in docs/src/):
docs/src/index.md- Main landing pagedocs/src/installation.md- Installation instructionsdocs/src/examples.md- Usage examples with code samplesdocs/src/reference.md- CLI reference with live examples (via click-extra sphinx)
Generated output:
docs/src/_build/html/- HTML documentation (deployed to GitHub Pages via semantic-release)docs/*.md- Markdown documentation (copied from build, committed during releases)
Using click-extra Sphinx Directives
The documentation uses click-extraβs Sphinx directives to show live CLI examples:
# Define CLI source (hidden by default)
\`\`\`{click:source}
:hide-results:
from lumos.cli import cli
\`\`\`
# Run CLI command and show output with ANSI colors
\`\`\`{click:run}
invoke(cli, args=["--help"])
\`\`\`Updating Documentation
- For CLI changes: Update docstrings in the source code. The CLI reference uses
click:rundirectives to execute commands and display their help. - For usage examples: Edit
docs/examples.mdwith new code samples. - For installation changes: Update
docs/installation.mdandREADME.md.
Release Process
Releases are automated via semantic-release and GitHub Actions.
Triggering a Release
- Go to the GitHub Actions page
- Select the βReleaseβ workflow
- Click βRun workflowβ
- Optionally enable βDry runβ to preview the release
What Happens During Release
- Version Analysis: semantic-release analyzes commits to determine the next version
- Build: Cross-platform binaries are built for Linux, macOS, and Windows
- Documentation: Documentation is regenerated with the new version
- Release:
CHANGELOG.mdis updatedpyproject.tomlversion is bumped- Git tag is created
- GitHub Release is published with binaries
- Homebrew formula is updated
Version Bumping
Version bumps are determined by commit messages:
feat:β Minor version bump (e.g., 1.0.0 β 1.1.0)fix:β Patch version bump (e.g., 1.0.0 β 1.0.1)BREAKING CHANGE:in commit body β Major version bump (e.g., 1.0.0 β 2.0.0)
Manual Release (Emergency)
If automated release fails:
# Update version manually
uv version X.Y.Z
# Build artifacts
uv build
uv run pyinstaller src/lumos/__main__.py
# Create and push tag
git tag vX.Y.Z
git push origin vX.Y.ZGetting Help
- Issues: GitHub Issues
- Discussions: GitHub Discussions
License
This project is licensed under the MIT License - see the LICENSE file for details.
Updated 1 day ago