Skip to content

Commit cce86e3

Browse files
committed
remove auth requirement for create command, fix path bug
1 parent 717f002 commit cce86e3

File tree

1 file changed

+3
-2
lines changed
  • src/codegen/cli/commands/create

1 file changed

+3
-2
lines changed

src/codegen/cli/commands/create/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,19 @@ def make_relative(path: Path) -> str:
6565

6666

6767
@click.command(name="create")
68-
@requires_init
6968
@click.argument("name", type=str)
7069
@click.argument("path", type=click.Path(path_type=Path), default=Path.cwd())
7170
@click.option("--description", "-d", default=None, help="Description of what this codemod does.")
7271
@click.option("--overwrite", is_flag=True, help="Overwrites function if it already exists.")
73-
def create_command(session: CodegenSession, name: str, path: Path, description: str | None = None, overwrite: bool = False):
72+
def create_command(name: str, path: Path, description: str | None = None, overwrite: bool = False):
7473
"""Create a new codegen function.
7574
7675
NAME is the name/label for the function
7776
PATH is where to create the function (default: current directory)
7877
"""
7978
# Get the target path for the function
8079
codemod_path, prompt_path = get_target_paths(name, path)
80+
session = CodegenSession()
8181

8282
# Check if file exists
8383
if codemod_path.exists() and not overwrite:
@@ -93,6 +93,7 @@ def create_command(session: CodegenSession, name: str, path: Path, description:
9393
with create_spinner("Generating function (using LLM, this will take ~10s)") as status:
9494
response = RestAPI(session.token).create(name=name, query=description)
9595
code = convert_to_cli(response.code, session.language, name)
96+
prompt_path.parent.mkdir(parents=True, exist_ok=True)
9697
prompt_path.write_text(response.context)
9798
else:
9899
# Use default implementation

0 commit comments

Comments
 (0)