mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-13 18:21:00 +00:00
- 在工具规范中添加 targetGroups 字段定义 - 扩展终端自动补全引擎以支持 hostGroup 参数传递 - 实现基于嵌套主机组成员资格的动态组目标过滤 - 更新 CLI 工具以支持 --target-groups 参数解析 - 添加代码片段导入导出中的动态组范围保留功能 - 增加相关测试用例验证组目标匹配逻辑
65 lines
1.6 KiB
JavaScript
65 lines
1.6 KiB
JavaScript
"use strict";
|
|
|
|
const test = require("node:test");
|
|
const assert = require("node:assert/strict");
|
|
|
|
const { parseArgs } = require("./netcatty-tool-cli.cjs");
|
|
|
|
test("parseArgs consumes attachment filename flag", () => {
|
|
const { positionals, opts } = parseArgs([
|
|
"node",
|
|
"netcatty-tool-cli",
|
|
"attachment",
|
|
"read",
|
|
"--filename",
|
|
"hosts.csv",
|
|
"--chat-session",
|
|
"chat-1",
|
|
"--json",
|
|
]);
|
|
|
|
assert.deepEqual(positionals, ["attachment", "read"]);
|
|
assert.equal(opts.filename, "hosts.csv");
|
|
assert.equal(opts.chatSessionId, "chat-1");
|
|
assert.equal(opts.json, true);
|
|
});
|
|
|
|
test("parseArgs consumes snippet multi-line run mode flag", () => {
|
|
const { positionals, opts } = parseArgs([
|
|
"node",
|
|
"netcatty-tool-cli",
|
|
"snippets",
|
|
"update",
|
|
"--snippet-id",
|
|
"snippet-1",
|
|
"--multi-line-run-mode",
|
|
"lineDelay",
|
|
"--json",
|
|
]);
|
|
|
|
assert.deepEqual(positionals, ["snippets", "update"]);
|
|
assert.equal(opts.snippetId, "snippet-1");
|
|
assert.equal(opts.multiLineRunMode, "lineDelay");
|
|
assert.equal(opts.json, true);
|
|
});
|
|
|
|
test("parseArgs consumes dynamic script group targets", () => {
|
|
const { positionals, opts } = parseArgs([
|
|
"node",
|
|
"netcatty-tool-cli",
|
|
"scripts",
|
|
"targets",
|
|
"set",
|
|
"--script-id",
|
|
"script-1",
|
|
"--target-groups",
|
|
'["Production","Staging/Web"]',
|
|
"--json",
|
|
]);
|
|
|
|
assert.deepEqual(positionals, ["scripts", "targets", "set"]);
|
|
assert.equal(opts.scriptId, "script-1");
|
|
assert.equal(opts.targetGroups, '["Production","Staging/Web"]');
|
|
assert.equal(opts.json, true);
|
|
});
|