Base Class
Tool
Abstract base for tool command argument construction.Provides consistent interface for constructing command-line arguments. Subclasses implement
name(), group(), badge_urls() and provide *_args() methods.Pattern:- Each tool method returns
Argsobject - Method names indicate command being constructed
- Arguments validated at construction
- Commands testable without execution
Abstract Methods (Must Implement)
Get tool command name.Returns:
Tool command name (e.g., “git”, “uv”, “pytest”).Example:
Returns the group the tool belongs to.Used for grouping badges in the README.md file.Returns:
Tool group constant from
ToolGroup.Example:Returns the URLs for a badge, like found in a README.md file.The first URL is the picture (badge image), and the second is the link where you are led when clicking on the badge.Returns:
A tuple of two strings that are URLs. Return empty strings if no badge.Example:
Instance Methods
Construct command arguments with tool name prepended.Parameters:Returns:
Args object with tool name and arguments.Example:
Command arguments.
Returns the badge string for a markdown file.Returns:
Markdown badge string combining badge image and link.Example:
Get tool dependencies.Returns:
Tuple of tool dependencies. Defaults to the name of the tool.Example:
Class Methods
Get a dict with all badges of tools grouped by their group.Returns:
Dictionary mapping group names to lists of badge markdown strings.Example:
Get all dev dependencies for all tools.Gets all subclasses of Tool and calls
dev_dependencies() on them. This way all dependencies for each tool are retrieved.Returns:
Sorted list of all tool dependencies.Example:Tool Groups
Constants for badge groups.Constants:
CI_CD = "ci/cd": CI/CD toolsCODE_QUALITY = "code-quality": Linters, formatters, type checkersDOCUMENTATION = "documentation": Documentation buildersPROJECT_INFO = "project-info": Project information toolsSECURITY = "security": Security scannersTOOLING = "tooling": Package managers and build toolsTESTING = "testing": Test frameworks and coverage tools
Args Type
Tuple subclass for command arguments.Methods:
run(*args, **kwargs) -> CompletedProcess: Execute the command__str__() -> str: Convert to space-separated string
Built-in Tools
PackageManager
UV package manager wrapper.Constructs uv command arguments for package management operations.Operations:
- Project setup: init, sync
- Dependencies: add, lock —upgrade
- Building: build, publish
- Versioning: version, version —bump patch
- Execution: run, run —no-group dev
- Self-maintenance: self update
PackageManager Methods
Get the name of the project from pyproject.toml.Returns:
Project name (kebab-case).
Get the main package of the project.Returns:
Package name (snake_case conversion of project name).
Construct uv init arguments.Returns:
Args for ‘uv init’.
Construct uv run arguments.Returns:
Args for ‘uv run’.
Construct uv run arguments without dev dependencies.Returns:
Args for ‘uv run —no-group dev’.
Construct uv add arguments.Returns:
Args for ‘uv add’.
Construct uv add arguments for dev dependencies.Returns:
Args for ‘uv add —group dev’.
Construct uv sync arguments.Returns:
Args for ‘uv sync’.
Construct uv sync arguments without dev dependencies.Returns:
Args for ‘uv sync —no-group dev’.
Construct uv lock arguments for updating dependencies.Returns:
Args for ‘uv lock —upgrade’.
Construct uv build arguments.Returns:
Args for ‘uv build’.
Construct uv publish arguments with token.Parameters:Returns:
Args for ‘uv publish —token
Authentication token (keyword-only).
<token>’.Construct uv version arguments.Returns:
Args for ‘uv version’.
Construct uv version arguments for patch bump.Returns:
Args for ‘uv version —bump patch’.
Linter
Ruff linter and formatter wrapper.Constructs ruff command arguments for linting and formatting operations.Operations:
- Linting: Check code for issues
- Formatting: Format code to style guidelines
- Auto-fix: Automatically fix linting issues
Linter Methods
Construct ruff check arguments.Returns:
Args for ‘ruff check’.
Construct ruff check arguments with auto-fix.Returns:
Args for ‘ruff check —fix’.
Construct ruff format arguments.Returns:
Args for ‘ruff format’.
Creating Custom Tools
Basic Tool
Tool with Custom Dependencies
Testing Tool Wrappers
Best Practices
- Use descriptive method names: Name methods after the command being constructed
- Accept variadic args: Use
*args: strto allow flexible argument passing - Return Args objects: Always return
Argsfrom wrapper methods - Provide badges: Include badge URLs for README generation
- Specify dependencies: Override
dev_dependencies()if tool needs plugins/extensions - Group appropriately: Use correct
ToolGroupconstant - Test without execution: Test command construction without running commands
- Use singleton access: Access via
.Iproperty for convenience
Related APIs
- CLI API - For command-line interface framework
- Configuration API - For managing project configuration files
- Builders API - For creating distributable artifacts