Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions hooks/rtk-rewrite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,18 @@ elif echo "$MATCH_CMD" | grep -qE '^pnpm[[:space:]]+(list|ls|outdated)([[:space:
REWRITTEN="${ENV_PREFIX}$(echo "$CMD_BODY" | sed 's/^pnpm /rtk pnpm /')"

# --- Python tooling ---
elif echo "$MATCH_CMD" | grep -qE '^uv[[:space:]]+'; then
REWRITTEN="${ENV_PREFIX}$(echo "$CMD_BODY" | sed 's/^uv /rtk uv /')"
elif echo "$MATCH_CMD" | grep -qE '^pytest([[:space:]]|$)'; then
REWRITTEN="${ENV_PREFIX}$(echo "$CMD_BODY" | sed 's/^pytest/rtk pytest/')"
elif echo "$MATCH_CMD" | grep -qE '^python[[:space:]]+-m[[:space:]]+pytest([[:space:]]|$)'; then
REWRITTEN="${ENV_PREFIX}$(echo "$CMD_BODY" | sed 's/^python -m pytest/rtk pytest/')"
elif echo "$MATCH_CMD" | grep -qE '^([^[:space:]]+/)?python(3)?[[:space:]]+-m[[:space:]]+pytest([[:space:]]|$)'; then
REWRITTEN="${ENV_PREFIX}$(echo "$CMD_BODY" | sed -E 's@^([^[:space:]]+/)?python(3)? -m pytest@rtk pytest@')"
elif echo "$MATCH_CMD" | grep -qE '^ruff[[:space:]]+(check|format)([[:space:]]|$)'; then
REWRITTEN="${ENV_PREFIX}$(echo "$CMD_BODY" | sed 's/^ruff /rtk ruff /')"
elif echo "$MATCH_CMD" | grep -qE '^pip[[:space:]]+(list|outdated|install|show)([[:space:]]|$)'; then
REWRITTEN="${ENV_PREFIX}$(echo "$CMD_BODY" | sed 's/^pip /rtk pip /')"
elif echo "$MATCH_CMD" | grep -qE '^uv[[:space:]]+pip[[:space:]]+(list|outdated|install|show)([[:space:]]|$)'; then
REWRITTEN="${ENV_PREFIX}$(echo "$CMD_BODY" | sed 's/^uv pip /rtk pip /')"

# --- Go tooling ---
elif echo "$MATCH_CMD" | grep -qE '^go[[:space:]]+test([[:space:]]|$)'; then
Expand Down
48 changes: 48 additions & 0 deletions hooks/test-rtk-rewrite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,34 @@ test_rewrite "npx prisma migrate" \
"npx prisma migrate" \
"rtk prisma migrate"

test_rewrite "uv pip list" \
"uv pip list" \
"rtk uv pip list"

test_rewrite "uv run python -m pytest -q" \
"uv run python -m pytest -q" \
"rtk uv run python -m pytest -q"

test_rewrite "uv run mypy" \
"uv run mypy src/" \
"rtk uv run mypy src/"

test_rewrite "uv run ruff" \
"uv run ruff check src/" \
"rtk uv run ruff check src/"

test_rewrite "uv run pylint" \
"uv run pylint src/" \
"rtk uv run pylint src/"

test_rewrite "uv run flake8" \
"uv run flake8 src/" \
"rtk uv run flake8 src/"

test_rewrite "uv sync --frozen" \
"uv sync --frozen" \
"rtk uv sync --frozen"

echo ""

# ---- SECTION 2: Env var prefix handling (THE BIG FIX) ----
Expand Down Expand Up @@ -149,6 +177,26 @@ test_rewrite "env + docker compose" \
"COMPOSE_PROJECT_NAME=test docker compose up -d" \
"COMPOSE_PROJECT_NAME=test rtk docker compose up -d"

test_rewrite "env + uv run pytest" \
"PYTHONPATH=. uv run python -m pytest tests/" \
"PYTHONPATH=. rtk uv run python -m pytest tests/"

test_rewrite "venv python pytest" \
".venv/bin/python -m pytest tests/unit/" \
"rtk pytest tests/unit/"

test_rewrite "env + venv python pytest" \
"PYTHONPATH=. .venv/bin/python -m pytest tests/unit/" \
"PYTHONPATH=. rtk pytest tests/unit/"

test_rewrite "ven python pytest" \
".ven/bin/python -m pytest tests/unit/" \
"rtk pytest tests/unit/"

test_rewrite "env + ven python pytest" \
"PYTHONPATH=. .ven/bin/python -m pytest tests/unit/" \
"PYTHONPATH=. rtk pytest tests/unit/"

echo ""

# ---- SECTION 3: New patterns ----
Expand Down
12 changes: 12 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ mod tracking;
mod tree;
mod tsc_cmd;
mod utils;
mod uv_cmd;
mod vitest_cmd;
mod wget_cmd;

Expand Down Expand Up @@ -505,6 +506,13 @@ enum Commands {
args: Vec<String>,
},

/// uv package manager/runner with first-class subcommand dispatch
Uv {
/// uv arguments (e.g., run, pip, sync)
#[arg(trailing_var_arg = true, allow_hyphen_values = true)]
args: Vec<String>,
},

/// Go commands with compact output
Go {
#[command(subcommand)]
Expand Down Expand Up @@ -1349,6 +1357,10 @@ fn main() -> Result<()> {
pip_cmd::run(&args, cli.verbose)?;
}

Commands::Uv { args } => {
uv_cmd::run(&args, cli.verbose)?;
}

Commands::Go { command } => match command {
GoCommands::Test { args } => {
go_cmd::run_test(&args, cli.verbose)?;
Expand Down
Loading