
- Renamed and updated the get_project_tree action to use a Python handler. - Added a new action load_file to load file content with a Python handler. - Renamed and updated the new_document action to new_file with a Python handler. - Added a new action search_text to search text in all files within the project. - Removed the old load_file action from the extension_demo workflow.
30 lines
643 B
Python
30 lines
643 B
Python
"""
|
|
Create new file.
|
|
arg:
|
|
content: current file name with content
|
|
fileName: new file name.
|
|
Rename content to fileName.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import shutil
|
|
|
|
def create_new_file(content_file, new_file):
|
|
"""
|
|
Create new file or replace file with new content.
|
|
"""
|
|
try:
|
|
if os.path.exists(new_file):
|
|
os.remove(new_file)
|
|
shutil.move(content_file, new_file)
|
|
except Exception as e:
|
|
sys.stderr.write(f"Error: {str(e)}\n")
|
|
sys.exit(1)
|
|
|
|
if __name__ == "__main__":
|
|
content_file = sys.argv[1]
|
|
new_file = sys.argv[2]
|
|
create_new_file(content_file, new_file)
|
|
sys.exit(0)
|