This directory contains example scripts that demonstrate various features and use cases for uvs.
A sophisticated command-line tool that demonstrates how to create a full-featured CLI application as a single file.
Features:
- Multiple subcommands with Click
- API integration with requests
- Rich terminal output with tables and progress bars
- Error handling and user feedback
- JSON processing and formatting
Dependencies:
requests>=2.25.0- HTTP client libraryclick>=8.0.0- Command-line interface frameworkrich>=10.0.0- Rich text and beautiful formatting
Installation:
uv run ../scripts/uvs.py examples/complex-cli.pyUsage:
# Fetch JSON from an API
complex-cli fetch https://api.github.com/users/python
# Show GitHub repositories for a user
complex-cli github python --limit 5
# Search PyPI packages
complex-cli search requests
# Display system information
complex-cli infoDemonstrates comprehensive PEP723 metadata usage and advanced features in a single-file script.
Features:
- Comprehensive PEP723 metadata (authors, classifiers, extras, etc.)
- Pydantic models for data validation
- HTTP client with httpx
- Modern CLI with Typer
- Rich terminal output
- Metadata introspection
Dependencies:
pydantic>=2.0.0- Data validation using Python type annotationshttpx>=0.24.0- Modern HTTP clienttyper>=0.9.0- Modern CLI framework
Recommended Dependencies:
rich>=13.0.0- Rich text and beautiful formattingipython>=8.0.0- Enhanced interactive Python shell
Development Extras:
pytest>=7.0.0- Testing frameworkblack>=23.0.0- Code formattermypy>=1.0.0- Static type checker
Installation:
uv run ../scripts/uvs.py examples/advanced-pep723.pyUsage:
# Display script information and metadata
advanced-pep723 info
# Fetch data from a URL
advanced-pep723 fetch https://api.github.com/users/python
# Demonstrate Pydantic validation
advanced-pep723 demo
# Display all PEP723 metadata
advanced-pep723 metadataTo install any of these examples:
- Navigate to the project root directory
- Run the installer with the example script path:
uv run scripts/uvs.py examples/complex-cli.py
- The tool will be available in your PATH with the same name as the script (with underscores converted to hyphens)
To remove an installed example using uvs:
uvs uninstall complex-cli
uvs uninstall advanced-pep723You can also uninstall all examples at once:
uvs uninstall --allFor a preview of what would be uninstalled:
uvs uninstall --dry-run complex-cliTo see which tools you've installed from examples:
uv run scripts/uvs.py --listTo find the source of a specific tool:
uv run scripts/uvs.py --which complex-cliWhen creating your own scripts based on these examples:
- Start with the PEP723 header to specify dependencies
- Include a
main()function as the entry point - Use appropriate CLI frameworks (Click, Typer, argparse) for command-line interfaces
- Add proper error handling and user feedback
- Include docstrings and comments for maintainability
# /// script
# requires-python = ">=3.8"
# dependencies = ["click"]
# ///
"""Your script description here."""
import click
@click.command()
def main():
"""Main entry point for your script."""
click.echo("Hello from your script!")
if __name__ == "__main__":
main()See PEP 723 for complete inline metadata specification.
- Dependency Management: Specify exact or minimum versions for dependencies
- Error Handling: Provide clear error messages and appropriate exit codes
- Documentation: Include docstrings and comments
- Testing: Test your script before installing it
- Versioning: Use semantic versioning for your scripts
- Metadata: Include comprehensive PEP723 metadata for better discoverability
If you encounter issues with the examples:
- Check that you have the latest version of
uvinstalled - Ensure all dependencies in the PEP723 header are available
- Use
--dry-runto inspect the generated package before installation - Check the
.uvs-registry.jsonfile for installation records - Use
uv tool listto see what tools are currently installed
To contribute new examples:
- Create a new script in this directory
- Add comprehensive documentation to this README
- Include a PEP723 header with all necessary dependencies
- Test the script thoroughly
- Submit a pull request with your example