Skip to content

remove auth requirement for create command, fix path bug #205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 30, 2025
Merged
Changes from 2 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
5 changes: 3 additions & 2 deletions src/codegen/cli/commands/create/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,19 @@ def make_relative(path: Path) -> str:


@click.command(name="create")
@requires_init
@click.argument("name", type=str)
@click.argument("path", type=click.Path(path_type=Path), default=Path.cwd())
@click.option("--description", "-d", default=None, help="Description of what this codemod does.")
@click.option("--overwrite", is_flag=True, help="Overwrites function if it already exists.")
def create_command(session: CodegenSession, name: str, path: Path, description: str | None = None, overwrite: bool = False):
def create_command(name: str, path: Path, description: str | None = None, overwrite: bool = False):
"""Create a new codegen function.

NAME is the name/label for the function
PATH is where to create the function (default: current directory)
"""
# Get the target path for the function
codemod_path, prompt_path = get_target_paths(name, path)
session = CodegenSession()

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