Add files via upload

This commit is contained in:
公明
2025-11-18 23:51:51 +08:00
committed by GitHub
parent 9325060e42
commit 0ce3364635
2 changed files with 73 additions and 16 deletions

View File

@@ -1,8 +1,33 @@
name: "execute-python-script"
command: "python3"
args: ["-c"]
command: "/bin/bash"
args:
- "-c"
- |
set -euo pipefail
SCRIPT_CONTENT="$1"
ENV_NAME="${2:-default}"
ADDITIONAL_ARGS="${3:-}"
BASE_DIR="${HOME}/.cyberstrike/venvs"
ENV_DIR="${BASE_DIR}/${ENV_NAME}"
mkdir -p "$BASE_DIR"
if [ ! -d "$ENV_DIR" ]; then
python3 -m venv "$ENV_DIR"
fi
# shellcheck disable=SC1090
source "$ENV_DIR/bin/activate"
if [ -n "$ADDITIONAL_ARGS" ]; then
python3 $ADDITIONAL_ARGS -c "$SCRIPT_CONTENT"
else
python3 -c "$SCRIPT_CONTENT"
fi
- "_"
enabled: true
short_description: "执行Python脚本工具"
short_description: "在指定虚拟环境中编写并执行Python脚本"
description: |
在虚拟环境中执行Python脚本。
@@ -29,6 +54,13 @@ parameters:
required: true
position: 0
format: "positional"
- name: "env_name"
type: "string"
description: "虚拟环境名称默认default"
required: false
default: "default"
position: 1
format: "positional"
- name: "additional_args"
type: "string"
description: |
@@ -43,3 +75,4 @@ parameters:
- 此参数会直接追加到命令末尾
required: false
format: "positional"
default: ""