mirror of
https://github.com/harivansh-afk/veet-code.git
synced 2026-04-15 07:04:49 +00:00
open solutions dir
This commit is contained in:
parent
05d86562ee
commit
a5fbb0a79e
2 changed files with 59 additions and 1 deletions
|
|
@ -54,9 +54,11 @@ uv sync
|
|||
|
||||
```bash
|
||||
veet # Launch TUI
|
||||
veet open # Open a problem in $EDITOR (vim)
|
||||
veet open two-sum # Open specific problem
|
||||
veet list # List all problems
|
||||
veet install-commands # Install Claude slash commands
|
||||
veet path # Show install location
|
||||
cd $(veet problems-dir) # cd to problems folder
|
||||
```
|
||||
|
||||
## Generate Problems
|
||||
|
|
|
|||
|
|
@ -95,6 +95,55 @@ def uninstall_commands() -> None:
|
|||
typer.echo(f"\nRemoved {count} commands")
|
||||
|
||||
|
||||
@app.command()
|
||||
def open(
|
||||
name: str = typer.Argument(None, help="Problem name (e.g., two-sum)"),
|
||||
) -> None:
|
||||
"""Open a problem in your editor ($EDITOR or vim)."""
|
||||
import os
|
||||
import subprocess
|
||||
from veetcode.app import scan_problems
|
||||
|
||||
repo = find_repo_root()
|
||||
problems = scan_problems(repo / "problems")
|
||||
|
||||
if not problems:
|
||||
typer.echo("No problems found.")
|
||||
raise typer.Exit(1)
|
||||
|
||||
# If no name given, show list and prompt
|
||||
if not name:
|
||||
typer.echo("Available problems:\n")
|
||||
for i, p in enumerate(problems, 1):
|
||||
diff = {"easy": "E", "medium": "M", "hard": "H"}.get(p.difficulty, "?")
|
||||
typer.echo(f" {i}. [{diff}] {p.name}")
|
||||
typer.echo()
|
||||
choice = typer.prompt("Enter number or name")
|
||||
|
||||
# Check if it's a number
|
||||
try:
|
||||
idx = int(choice) - 1
|
||||
if 0 <= idx < len(problems):
|
||||
name = problems[idx].name
|
||||
else:
|
||||
typer.echo("Invalid number")
|
||||
raise typer.Exit(1)
|
||||
except ValueError:
|
||||
name = choice
|
||||
|
||||
# Find the problem
|
||||
problem = next((p for p in problems if p.name == name), None)
|
||||
if not problem:
|
||||
typer.echo(f"Problem not found: {name}")
|
||||
raise typer.Exit(1)
|
||||
|
||||
solution_file = problem.path / "solution.py"
|
||||
editor = os.environ.get("EDITOR", "vim")
|
||||
|
||||
typer.echo(f"Opening {solution_file} in {editor}...")
|
||||
subprocess.run([editor, str(solution_file)])
|
||||
|
||||
|
||||
@app.command()
|
||||
def path() -> None:
|
||||
"""Show veetcode installation path."""
|
||||
|
|
@ -102,5 +151,12 @@ def path() -> None:
|
|||
typer.echo(repo)
|
||||
|
||||
|
||||
@app.command()
|
||||
def problems_dir() -> None:
|
||||
"""Print the problems directory path (useful for cd)."""
|
||||
repo = find_repo_root()
|
||||
typer.echo(repo / "problems")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue