Skip to content

Commit

Permalink
✨ add snk create command
Browse files Browse the repository at this point in the history
  • Loading branch information
Wytamma committed Nov 16, 2024
1 parent 40a3360 commit d3fcfb8
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions snk/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,34 @@ def list(
console = Console()
console.print(table)

@app.command()
def create(path: Path, force: bool = typer.Option(False, "--force", "-f")):
"""Create a default snk.yaml project that can be installed with snk"""
if path.exists():
if not force:
typer.secho(f"Directory '{path}' already exists! Use --force to overwrite.", fg="red", err=True)
raise typer.Exit(1)
else:
typer.secho(f"Overwriting existing directory '{path}'.", fg="yellow", err=True)
import shutil
shutil.rmtree(path)
try:
path.mkdir(parents=True, exist_ok=False)
except FileExistsError:
typer.secho(f"Directory '{path}' already exists! Use --force to overwrite.", fg="red", err=True)
raise typer.Exit(1)
snk_config = SnkConfig.from_workflow_dir(path, create_if_not_exists=True)
snk_config.cli["msg"] = {
"help": "Print a help message.",
"default": "Hello, World!",
"required": False,
"short": "m",
}
snk_config.save()
typer.echo(f"Created snk.yaml at {snk_config._snk_config_path}")
with open(path / "Snakefile", "w") as f:
f.write("""rule all:\n shell: f"echo {config['msg']}"\n""")

@app.command()
def edit(
ctx: typer.Context,
Expand Down

0 comments on commit d3fcfb8

Please sign in to comment.