Add files via upload

This commit is contained in:
公明
2025-11-17 19:27:50 +08:00
committed by GitHub
parent 3fbc4aa672
commit 6ff582041c
+36 -8
View File
@@ -1,9 +1,35 @@
name: "create-file" name: "create-file"
command: "sh" command: "python3"
args:
- "-c"
- |
import base64
import sys
from pathlib import Path
if len(sys.argv) < 3:
sys.stderr.write("Usage: create-file <filename> <content> [binary]\n")
sys.exit(1)
filename = sys.argv[1]
content = sys.argv[2]
binary_arg = sys.argv[3].lower() if len(sys.argv) > 3 else "false"
binary = binary_arg in ("1", "true", "yes", "on")
path = Path(filename)
if not path.is_absolute():
path = Path.cwd() / path
path.parent.mkdir(parents=True, exist_ok=True)
if binary:
data = base64.b64decode(content)
path.write_bytes(data)
else:
path.write_text(content, encoding="utf-8")
print(f"文件已创建: {path}")
enabled: true enabled: true
short_description: "创建文件工具" short_description: "创建文件工具"
description: | description: |
在服务器上创建指定内容的文件。 在服务器上创建指定内容的文件。
@@ -16,24 +42,26 @@ description: |
- 文件创建 - 文件创建
- 脚本生成 - 脚本生成
- 数据保存 - 数据保存
parameters: parameters:
- name: "filename" - name: "filename"
type: "string" type: "string"
description: "要创建的文件名" description: "要创建的文件名"
required: true required: true
position: 0
format: "positional"
- name: "content" - name: "content"
type: "string" type: "string"
description: "文件内容" description: "文件内容"
required: true required: true
position: 1
format: "positional"
- name: "binary" - name: "binary"
type: "bool" type: "bool"
description: "是否为二进制内容" description: "内容是否为Base64编码的二进制"
required: false required: false
position: 2
format: "positional"
default: false default: false
- name: "additional_args" - name: "additional_args"
type: "string" type: "string"
description: | description: |