惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Apple Machine Learning Research
Apple Machine Learning Research
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
G
Google Developers Blog
博客园 - 司徒正美
J
Java Code Geeks
aimingoo的专栏
aimingoo的专栏
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
T
The Blog of Author Tim Ferriss
D
Docker
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
腾讯CDC
V
Visual Studio Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
C
Check Point Blog
M
MIT News - Artificial intelligence
Jina AI
Jina AI
I
InfoQ
雷峰网
雷峰网
The Cloudflare Blog
美团技术团队
Engineering at Meta
Engineering at Meta

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(test): guard sqlite benchmark cli args · openclaw/ope...
vincentkoc · 2026-06-20 · via Recent Commits to openclaw:main

@@ -110,20 +110,45 @@ type CliOptions = {

110110

stateDir: string | null;

111111

};

112112113-

function parseFlagValue(flag: string): string | undefined {

114-

const index = process.argv.indexOf(flag);

113+

const BOOLEAN_FLAGS = new Set(["--help"]);

114+

const VALUE_FLAGS = new Set(["--output", "--profile", "--state-dir"]);

115+116+

class CliUsageError extends Error {

117+

override name = "CliUsageError";

118+

}

119+120+

function parseFlagValue(flag: string, argv: string[]): string | undefined {

121+

const index = argv.indexOf(flag);

115122

if (index === -1) {

116123

return undefined;

117124

}

118-

const value = process.argv[index + 1];

125+

const value = argv[index + 1];

119126

if (!value || value.startsWith("--")) {

120-

throw new Error(`${flag} requires a value`);

127+

throw new CliUsageError(`${flag} requires a value`);

121128

}

122129

return value;

123130

}

124131125-

function hasFlag(flag: string): boolean {

126-

return process.argv.includes(flag);

132+

function hasFlag(flag: string, argv = process.argv.slice(2)): boolean {

133+

return argv.includes(flag);

134+

}

135+136+

function validateArgs(argv: string[]): void {

137+

for (let index = 0; index < argv.length; index += 1) {

138+

const arg = argv[index] ?? "";

139+

if (BOOLEAN_FLAGS.has(arg)) {

140+

continue;

141+

}

142+

if (VALUE_FLAGS.has(arg)) {

143+

const value = argv[index + 1];

144+

if (!value || value.startsWith("--")) {

145+

throw new CliUsageError(`${arg} requires a value`);

146+

}

147+

index += 1;

148+

continue;

149+

}

150+

throw new CliUsageError(`Unknown argument: ${arg}`);

151+

}

127152

}

128153129154

function parseProfile(raw: string | undefined): ProfileId {

@@ -133,14 +158,17 @@ function parseProfile(raw: string | undefined): ProfileId {

133158

if (raw === "smoke" || raw === "default" || raw === "large") {

134159

return raw;

135160

}

136-

throw new Error(`--profile must be one of smoke, default, large; got ${JSON.stringify(raw)}`);

161+

throw new CliUsageError(

162+

`--profile must be one of smoke, default, large; got ${JSON.stringify(raw)}`,

163+

);

137164

}

138165139-

function parseOptions(): CliOptions {

166+

function parseOptions(argv = process.argv.slice(2)): CliOptions {

167+

validateArgs(argv);

140168

return {

141-

output: parseFlagValue("--output") ?? null,

142-

profile: parseProfile(parseFlagValue("--profile")),

143-

stateDir: parseFlagValue("--state-dir") ?? null,

169+

output: parseFlagValue("--output", argv) ?? null,

170+

profile: parseProfile(parseFlagValue("--profile", argv)),

171+

stateDir: parseFlagValue("--state-dir", argv) ?? null,

144172

};

145173

}

146174

@@ -535,11 +563,13 @@ function printProofLines(report: BenchmarkReport): void {

535563

}

536564537565

function main(): void {

538-

if (hasFlag("--help")) {

566+

const argv = process.argv.slice(2);

567+

validateArgs(argv);

568+

if (hasFlag("--help", argv)) {

539569

printUsage();

540570

return;

541571

}

542-

const options = parseOptions();

572+

const options = parseOptions(argv);

543573

const config = applyScale(PROFILES[options.profile]);

544574

const stateDir =

545575

options.stateDir ?? fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-sqlite-perf-"));

@@ -626,5 +656,13 @@ function main(): void {

626656

}

627657628658

if (import.meta.url === pathToFileURL(process.argv[1] ?? "").href) {

629-

main();

659+

try {

660+

main();

661+

} catch (error) {

662+

if (error instanceof CliUsageError) {

663+

console.error(`error: ${error.message}`);

664+

process.exit(2);

665+

}

666+

throw error;

667+

}

630668

}