CLI tool to automate git worktree and Docker Compose development workflows
Project description
sprout
A CLI tool to automate git worktree and Docker Compose development workflows.
Features
- ๐ฑ Create isolated development environments using git worktrees
- ๐ง Automatic
.envfile generation from templates - ๐ข Smart port allocation to avoid conflicts
- ๐ Centralized worktree management in
.sprout/directory - ๐จ Beautiful CLI interface with colors and tables
Installation
pip install sprout
For development:
# Clone the repository
git clone https://github.com/SecDev-Lab/sprout.git
cd sprout
# Install in development mode
pip install -e ".[dev]"
Quick Start
- Create a
.env.exampletemplate in your project root:
# API Configuration
API_KEY={{ API_KEY }}
API_PORT={{ auto_port() }}
# Database Configuration
DB_HOST=localhost
DB_PORT={{ auto_port() }}
# Example: Docker Compose variables (preserved as-is)
# sprout will NOT process ${...} syntax - it's passed through unchanged
# DB_NAME=${DB_NAME}
- Create and navigate to a new development environment in one command:
cd $(sprout create feature-branch --path)
This single command:
- Creates a new git worktree for
feature-branch - Generates a
.envfile from your template - Outputs the path to the new environment
- Changes to that directory when wrapped in
cd $(...)
- Start your services:
docker compose up -d
Alternative: Two-Step Process
If you prefer to see the creation output first:
# Create the environment
sprout create feature-branch
# Then navigate to it
cd $(sprout path feature-branch)
Commands
sprout create <branch-name> [--path]
Create a new development environment with automated setup.
Options:
--path: Output only the worktree path (useful for shell command substitution)
Examples:
# Create and see progress messages
sprout create feature-xyz
# Create and navigate in one command
cd $(sprout create feature-xyz --path)
sprout ls
List all managed development environments with their status.
The output includes index numbers that can be used with other commands:
sprout ls
# Output:
# โโโโโโโโณโโโโโโโโโโโโโโโโโโณโโโโโโโโโโโโโโโโโโณโโโโโโโโโณโโโโโโโโโโโโโโโโโโโ
# โ No. โ Branch โ Path โ Status โ Last Modified โ
# โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
# โ 1 โ feature-auth โ .sprout/feat... โ โ 2025-06-27 14:30 โ
# โ 2 โ bugfix-api โ .sprout/bugf... โ โ 2025-06-27 15:45 โ
# โโโโโโโโดโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโดโโโโโโโโโดโโโโโโโโโโโโโโโโโโโ
sprout rm <branch-name-or-index>
Remove a development environment (with confirmation prompts).
You can use either the branch name or the index number from sprout ls:
# Remove by branch name
sprout rm feature-auth
# Remove by index number
sprout rm 1
sprout path <branch-name-or-index>
Get the filesystem path of a development environment.
You can use either the branch name or the index number from sprout ls:
# Get path by branch name
sprout path feature-auth
# Output: /path/to/project/.sprout/feature-auth
# Get path by index number
sprout path 1
# Output: /path/to/project/.sprout/feature-auth
# Use with cd command
cd $(sprout path 2)
sprout --version
Show the version of sprout.
Template Syntax
sprout supports two types of placeholders in .env.example:
-
Variable Placeholders:
{{ VARIABLE_NAME }}- First: Checks if the variable exists in your environment (e.g.,
export API_KEY=xxx) - Then: If not found in environment, prompts for user input
- Example:
{{ API_KEY }}will use$API_KEYif set, otherwise asks you to enter it
- First: Checks if the variable exists in your environment (e.g.,
-
Auto Port Assignment:
{{ auto_port() }}- Automatically assigns available ports
- Avoids conflicts with other sprout environments
- Checks system port availability
-
Docker Compose Syntax (Preserved):
${VARIABLE}- NOT processed by sprout - passed through as-is
- Useful for Docker Compose variable substitution
- Example:
${DB_NAME:-default}remains unchanged in generated.env
Environment Variable Resolution Example
# Set environment variable
export API_KEY="my-secret-key"
# Create sprout environment - API_KEY will be automatically used
sprout create feature-branch
# โ API_KEY in .env will be set to "my-secret-key" without prompting
# For unset variables, sprout will prompt
sprout create another-branch
# โ Enter a value for 'DATABASE_URL': [user input required]
Documentation
- Architecture Overview - Design philosophy, architecture, and implementation details
- Detailed Usage Guide - Comprehensive usage examples and troubleshooting
Development
Setup
# Install development dependencies
make setup
Testing
# Run tests
make test
# Run tests with coverage
make test-cov
Code Quality
# Run linter
make lint
# Format code
make format
# Run type checking
make typecheck
Requirements
- Python 3.11+
- Git
- Docker Compose (optional, for Docker-based workflows)
License
See LICENSE file.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sprout_cli-0.3.0.tar.gz.
File metadata
- Download URL: sprout_cli-0.3.0.tar.gz
- Upload date:
- Size: 16.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60cd6cf4c543e60065bb994364bdbfb95fe718efd42e4aefaf7bbafced2ddcb2
|
|
| MD5 |
3c6099ba79ec78897b8a6f57d98fad12
|
|
| BLAKE2b-256 |
135bae6f7c2a2413b6f4e4ba0d35c288b129214fa7b62b10d46a21b8742c65af
|
File details
Details for the file sprout_cli-0.3.0-py3-none-any.whl.
File metadata
- Download URL: sprout_cli-0.3.0-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0499d120698f0b916e6c556f8c5c50e90ef091ffda39732074de5aa66668baee
|
|
| MD5 |
b3c498fdf06b5ae502c7f26309bd5374
|
|
| BLAKE2b-256 |
a353e96ebb412a6dac3ca770547d3f8a93a5a2a0fb9f08002ad5e234cd23e4c7
|