Files
CyberStrikeAI/tools/anew.yaml
2025-11-21 23:18:21 +08:00

82 lines
1.9 KiB
YAML
Raw Permalink 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.
name: "anew"
command: "python3"
args:
- "-c"
- |
import shlex
import subprocess
import sys
if len(sys.argv) < 2:
sys.stderr.write("缺少输入数据\n")
sys.exit(1)
input_data = sys.argv[1]
output_file = sys.argv[2] if len(sys.argv) > 2 else ""
additional = sys.argv[3] if len(sys.argv) > 3 else ""
cmd = ["anew"]
if additional:
cmd.extend(shlex.split(additional))
if output_file:
cmd.append(output_file)
proc = subprocess.run(
cmd,
input=input_data.encode("utf-8"),
capture_output=True,
text=True,
)
if proc.returncode != 0:
sys.stderr.write(proc.stderr or proc.stdout)
sys.exit(proc.returncode)
sys.stdout.write(proc.stdout)
enabled: true
short_description: "数据去重工具,用于处理文件中的新行"
description: |
Anew是一个数据去重工具用于将新行追加到文件中自动过滤重复项。
**主要功能:**
- 数据去重
- 文件追加
- 唯一行过滤
- 快速处理
**使用场景:**
- 数据处理
- 结果去重
- 数据合并
- 工具链集成
parameters:
- name: "input_data"
type: "string"
description: "输入数据"
required: true
position: 0
format: "positional"
- name: "output_file"
type: "string"
description: "输出文件路径"
required: false
default: ""
position: 1
format: "positional"
- name: "additional_args"
type: "string"
description: |
额外的anew参数。用于传递未在参数列表中定义的anew选项。
**示例值:**
- 根据工具特性添加常用参数示例
**注意事项:**
- 多个参数用空格分隔
- 确保参数格式正确,避免命令注入
- 此参数会直接追加到命令末尾
required: false
default: ""
position: 2
format: "positional"