Compare commits

..
5 Commits
Author SHA1 Message Date
yunyingk cf5d12b0a5 Merge pull request #42 from yunyingk/fix/case-insensitive-version-and-help
🚀 Release / 🚀 Build & Publish Multi-Platform Binaries (push) Has been cancelled
fix(cli): support case-insensitive version & help aliases and bump to v0.6.1
2026-09-05 22:17:48 +08:00
gitea 535404871c chore(release): bump version to v0.6.1 2026-09-05 22:17:32 +08:00
gitea 269b7e8f0f fix(cli): support case-insensitive version and help flags and subcommands 2026-09-05 22:16:56 +08:00
yunyingk c99c5d98ec Merge pull request #41 from yunyingk/fix/version-and-help-aliases
fix(cli): support version and help aliases (v, V, -V, h, -h)
2026-09-05 22:14:22 +08:00
gitea 4fbd737402 fix(cli): support version and help aliases (v, V, -V, h, -h) 2026-09-05 22:13:57 +08:00
10 changed files with 111 additions and 15 deletions

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hose-use",
"version": "0.6.0",
"version": "0.6.1",
"description": "合思/易快报 (ekuaibao) 企业级 SaaS CLI 与底层 SDK:多账号登录、企业租户切换、单据明细检索、工作流管理、内置 HTTP 服务与常驻守护进程。",
"author": {
"name": "yingqing"
+1 -1
View File
@@ -1,4 +1,4 @@
# hose-use (v0.6.0)
# hose-use (v0.6.1)
合思/易快报(ekuaibao)企业级 CLI 命令行工具与底层 SDK。
+1 -1
View File
@@ -2,7 +2,7 @@
"openapi": "3.1.0",
"info": {
"title": "hose-use API & MCP Tools Specification",
"version": "0.6.0",
"version": "0.6.1",
"description": "Unified Enterprise SaaS API, CLI, and MCP Specification for Ekuaibao (合思/易快报), EASO, and Piper Workflows."
},
"servers": [
+1 -1
View File
@@ -1,7 +1,7 @@
openapi: 3.1.0
info:
title: hose-use API & MCP Tools Specification
version: 0.6.0
version: 0.6.1
description: >-
Unified Enterprise SaaS API, CLI, and MCP Specification for Ekuaibao (合思/易快报), EASO, and Piper Workflows.
servers:
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hose-use",
"version": "0.6.0",
"version": "0.6.1",
"module": "src/server.ts",
"type": "module",
"bin": {
+1 -1
View File
@@ -6,7 +6,7 @@ metadata:
short-description: 合思/易快报企业级 CLI 工具与底层 SDK (v0.6.0)
---
# hose-use (v0.6.0)
# hose-use (v0.6.1)
在具备 MCP 的 AI 智能体环境中,**优先使用 `hose_cli` 单工具网关**,传入 `command: string` 执行;在终端或自动化脚本中,直接调用全局 `hose` 或 `hose-use` 命令行。
本 Skill 是智能体的路由分发层:保持主文档简明,遇到复杂业务时深入查阅对应的专属参考文档(`references/*.md`)。
+12 -5
View File
@@ -8,6 +8,7 @@ const KNOWN_BOOLEAN_FLAGS = new Set([
"h",
"version",
"v",
"V",
"force",
"f",
"stateless",
@@ -48,8 +49,10 @@ export function parseArgs(rawArgs: string[]): CliParsedArgs {
options[key] = val;
} else {
const key = arg.slice(2);
if (KNOWN_BOOLEAN_FLAGS.has(key)) {
const keyLower = key.toLowerCase();
if (KNOWN_BOOLEAN_FLAGS.has(key) || KNOWN_BOOLEAN_FLAGS.has(keyLower)) {
options[key] = true;
if (key !== keyLower) options[keyLower] = true;
} else {
const next = rawArgs[i + 1];
if (next && !next.startsWith("-")) {
@@ -65,10 +68,14 @@ export function parseArgs(rawArgs: string[]): CliParsedArgs {
if (arg.startsWith("-") && arg.length > 1) {
const flag = arg.slice(1);
if (flag === "h") options.help = true;
else if (flag === "j") options.json = true;
else if (flag === "v") options.version = true;
else if (flag === "o") {
const flagLower = flag.toLowerCase();
if (flagLower === "h" || flag === "?") {
options.help = true;
} else if (flagLower === "j") {
options.json = true;
} else if (flagLower === "v") {
options.version = true;
} else if (flag === "o") {
const next = rawArgs[i + 1];
if (next && !next.startsWith("-")) {
options.outputFile = next;
+63
View File
@@ -0,0 +1,63 @@
import { describe, expect, it } from "bun:test";
import { runCli } from "./runner.js";
import { VERSION } from "../version.js";
describe("CLI runner - version and help aliases", () => {
const versionVariants = [
["version"],
["verSion"],
["versioN"],
["VERSION"],
["Version"],
["v"],
["V"],
["-v"],
["-V"],
["--version"],
["--verSion"],
["--VERSION"],
["--v"],
["--V"],
];
for (const args of versionVariants) {
it(`correctly outputs version for "${args.join(" ")}"`, async () => {
const result = await runCli(args);
expect(result.exitCode).toBe(0);
expect(result.stderr).toBe("");
expect(result.stdout).toBe(`hose-use v${VERSION}\n`);
});
}
const helpVariants = [
[],
["help"],
["HeLp"],
["HELP"],
["h"],
["H"],
["-h"],
["-H"],
["--help"],
["--HeLp"],
["--HELP"],
["?"],
["-?"],
];
for (const args of helpVariants) {
it(`correctly outputs help for "${args.join(" ") || "<empty>"}"`, async () => {
const result = await runCli(args);
expect(result.exitCode).toBe(0);
expect(result.stderr).toBe("");
expect(result.stdout).toContain(`合思/易快报企业级 CLI 工具 (hose-use) v${VERSION}`);
expect(result.stdout).toContain("用法:");
});
}
it("handles unknown commands gracefully", async () => {
const result = await runCli(["unknown-command-xyz"]);
expect(result.exitCode).toBe(1);
expect(result.stderr).toContain("未知命令域: unknown-command-xyz");
});
});
+29 -3
View File
@@ -21,7 +21,7 @@ import { handleMessageCommand } from "./commands/message.js";
import { handleDimensionCommand } from "./commands/dimension.js";
import { handleRoleCommand } from "./commands/role.js";
import { handlePermissionCommand } from "./commands/permission.js";
import type { CliResult, CliRunOptions } from "./types.js";
import type { CliParsedArgs, CliResult, CliRunOptions } from "./types.js";
const STANDING_COMMANDS = new Set(["http", "server", "web", "mcp"]);
@@ -82,17 +82,43 @@ async function runCliOnce(
}
}
function isHelpRequested(parsed: CliParsedArgs): boolean {
const normArea = (parsed.area || "").replace(/^-+/, "").toLowerCase();
if (normArea === "help" || normArea === "h" || normArea === "?") return true;
for (const [key, val] of Object.entries(parsed.options)) {
const normKey = key.replace(/^-+/, "").toLowerCase();
if (normKey === "help" || normKey === "h" || normKey === "?") {
if (val === true || val === "true" || val === "") return true;
}
}
return false;
}
function isVersionRequested(parsed: CliParsedArgs): boolean {
const normArea = (parsed.area || "").replace(/^-+/, "").toLowerCase();
if (normArea === "version" || normArea === "v") return true;
for (const [key, val] of Object.entries(parsed.options)) {
const normKey = key.replace(/^-+/, "").toLowerCase();
if (normKey === "version" || normKey === "v") {
if (val === true || val === "true" || val === "") return true;
}
}
return false;
}
async function dispatchCli(
rawArgs: string[],
options: CliRunOptions = {}
): Promise<CliResult> {
const parsed = parseArgs(rawArgs);
if (booleanOption(parsed.options, ["help", "h"]) || parsed.area === "help") {
if (isHelpRequested(parsed)) {
return { stdout: printHelp() + "\n", stderr: "", exitCode: 0 };
}
if (booleanOption(parsed.options, ["version", "v"]) || parsed.area === "version") {
if (isVersionRequested(parsed)) {
return { stdout: `hose-use v${VERSION}\n`, stderr: "", exitCode: 0 };
}
+1 -1
View File
@@ -1 +1 @@
export const VERSION = "0.6.0";
export const VERSION = "0.6.1";