@@ -65,19 +65,19 @@ def make_relative(path: Path) -> str:
65
65
66
66
67
67
@click .command (name = "create" )
68
- @requires_init
69
68
@click .argument ("name" , type = str )
70
69
@click .argument ("path" , type = click .Path (path_type = Path ), default = Path .cwd ())
71
70
@click .option ("--description" , "-d" , default = None , help = "Description of what this codemod does." )
72
71
@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 ):
74
73
"""Create a new codegen function.
75
74
76
75
NAME is the name/label for the function
77
76
PATH is where to create the function (default: current directory)
78
77
"""
79
78
# Get the target path for the function
80
79
codemod_path , prompt_path = get_target_paths (name , path )
80
+ session = CodegenSession ()
81
81
82
82
# Check if file exists
83
83
if codemod_path .exists () and not overwrite :
@@ -93,6 +93,7 @@ def create_command(session: CodegenSession, name: str, path: Path, description:
93
93
with create_spinner ("Generating function (using LLM, this will take ~10s)" ) as status :
94
94
response = RestAPI (session .token ).create (name = name , query = description )
95
95
code = convert_to_cli (response .code , session .language , name )
96
+ prompt_path .parent .mkdir (parents = True , exist_ok = True )
96
97
prompt_path .write_text (response .context )
97
98
else :
98
99
# Use default implementation
0 commit comments