Files
Netcatty/electron/cli/netcatty-tool-cli.test.cjs
T
yintian a47de3cb52 feat(terminal): 添加动态组目标支持到代码片段功能
- 在工具规范中添加 targetGroups 字段定义
- 扩展终端自动补全引擎以支持 hostGroup 参数传递
- 实现基于嵌套主机组成员资格的动态组目标过滤
- 更新 CLI 工具以支持 --target-groups 参数解析
- 添加代码片段导入导出中的动态组范围保留功能
- 增加相关测试用例验证组目标匹配逻辑
2026-08-12 09:23:27 +08:00

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);
});