bobo.yang c794e27c02 Update and add new actions in auto_command workflow
- 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.
2023-08-09 00:16:03 +08:00

25 lines
858 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
get project files by "git ls-files" command
如果项目文件数超出100那么结束执行退出码为1并且输出英文”文件数太多需要通过ls命令逐层查看各个目录中的文件、目录结构信息“
"""
import subprocess
import sys
def get_project_tree():
"""
Get project files by "git ls-files" command
"""
try:
output = subprocess.check_output(["git", "ls-files"]).decode("utf-8").split("\n")
if len(output) > 100:
sys.stderr.write("Error: Too many files, you need to view the files and directory structure in each directory through the 'ls' command.\n")
sys.exit(1)
return output
except Exception as e:
sys.stderr.write(f"Error: {str(e)}\n")
sys.exit(1)
if __name__ == "__main__":
print(get_project_tree())
sys.exit(0)