File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -354,21 +354,23 @@ def scroll_up(self) -> str:
354354 output += self ._print_window (self .current_file , self .current_line , self .window )
355355 return output
356356
357- async def create_file (self , filename : str ) -> str :
358- """Creates and opens a new file with the given name.
357+ async def create_file (self , filename : str , content : str = "" ) -> str :
358+ """Creates and opens a new file with the given name and optional content .
359359
360360 Args:
361- filename: str: The name of the file to create. If the parent directory does not exist, it will be created.
361+ filename: str: The name of the file to create.
362+ content: str: (Optional) The initial content to write to the file.
362363 """
363364 filename = self ._try_fix_path (filename )
364365
365366 if filename .exists ():
366367 raise FileExistsError (f"File '{ filename } ' already exists." )
367- await awrite (filename , "\n " )
368+
369+ # Write content if provided, otherwise default to newline
370+ await awrite (filename , content if content else "\n " )
368371
369372 self .open_file (filename )
370- return f"[File { filename } created.]"
371-
373+ return f"[File { filename } created with { len (content )} characters.]"
372374 @staticmethod
373375 def _append_impl (lines , content ):
374376 """Internal method to handle appending to a file.
You can’t perform that action at this time.
0 commit comments