Merge pull request #42 from yunyingk/fix/case-insensitive-version-and-help

fix(cli): support case-insensitive version & help aliases and bump to v0.6.1
This commit is contained in:
yunyingk authored and GitHub committed 2026-09-05 22:17:48 +08:00
commit bb7bc264a0
10 files changed
+63 -29

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`)。
+11 -5
View File
@@ -49,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("-")) {
@@ -66,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" || 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;
+16
View File
@@ -5,11 +5,19 @@ 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) {
@@ -24,9 +32,17 @@ describe("CLI runner - version and help aliases", () => {
const helpVariants = [
[],
["help"],
["HeLp"],
["HELP"],
["h"],
["H"],
["-h"],
["-H"],
["--help"],
["--HeLp"],
["--HELP"],
["?"],
["-?"],
];
for (const args of helpVariants) {
+29 -17
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,31 +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" ||
parsed.area === "h" ||
parsed.area === "-h" ||
parsed.area === "--help"
) {
if (isHelpRequested(parsed)) {
return { stdout: printHelp() + "\n", stderr: "", exitCode: 0 };
}
if (
booleanOption(parsed.options, ["version", "v", "V"]) ||
parsed.area === "version" ||
parsed.area === "v" ||
parsed.area === "V" ||
parsed.area === "-v" ||
parsed.area === "-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";