mirror of
https://github.com/iflytek/skillhub.git
synced 2026-09-16 23:41:19 +00:00
feat(cli): move namespaces to me subcommand and reorganize help categories
- Add 'me namespaces' subcommand to list accessible namespaces - Remove standalone 'namespaces' command from CLI - Rename 'My Skills' help section to 'My Profile' - Move namespaces listing under My Profile section Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
parent
d273cac65c
commit
0bfcb028c2
2 changed files with 30 additions and 6 deletions
|
|
@ -64,9 +64,10 @@ function buildTopLevelHelp(version: string): string {
|
|||
]));
|
||||
sections.push("");
|
||||
|
||||
sections.push(formatSection("My Skills", [
|
||||
sections.push(formatSection("My Profile", [
|
||||
{ cmd: "me skills", desc: "List your published skills", alias: "me ls" },
|
||||
{ cmd: "me stars", desc: "List your starred skills" },
|
||||
{ cmd: "me namespaces", desc: "List namespaces you have access to" },
|
||||
{ cmd: "rating <skill>", desc: "View your rating for a skill" },
|
||||
{ cmd: "reviews", desc: "List your review submissions", alias: "reviews my, reviews submissions" },
|
||||
]));
|
||||
|
|
@ -96,7 +97,6 @@ function buildTopLevelHelp(version: string): string {
|
|||
|
||||
sections.push(formatSection("Notifications & Admin", [
|
||||
{ cmd: "notifications", desc: "Manage notifications", alias: "notif" },
|
||||
{ cmd: "namespaces", desc: "List namespaces you have access to" },
|
||||
{ cmd: "transfer <ns> <user>", desc: "Transfer namespace ownership" },
|
||||
]));
|
||||
sections.push("");
|
||||
|
|
@ -158,7 +158,6 @@ export async function createCli(): Promise<Command> {
|
|||
{ registerLogout },
|
||||
{ registerWhoami },
|
||||
{ registerPublish },
|
||||
{ registerNamespaces },
|
||||
{ registerInstall },
|
||||
{ registerDownload },
|
||||
{ registerList },
|
||||
|
|
@ -186,7 +185,6 @@ export async function createCli(): Promise<Command> {
|
|||
import("./commands/logout.js"),
|
||||
import("./commands/whoami.js"),
|
||||
import("./commands/publish.js"),
|
||||
import("./commands/namespaces.js"),
|
||||
import("./commands/install.js"),
|
||||
import("./commands/download.js"),
|
||||
import("./commands/list.js"),
|
||||
|
|
@ -215,7 +213,6 @@ export async function createCli(): Promise<Command> {
|
|||
registerLogout(program);
|
||||
registerWhoami(program);
|
||||
registerPublish(program);
|
||||
registerNamespaces(program);
|
||||
registerInstall(program);
|
||||
registerDownload(program);
|
||||
registerList(program);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ export interface MeSkillsResponse {
|
|||
}
|
||||
|
||||
export function registerMe(program: Command) {
|
||||
const me = program.command("me").description("View your skills and stars");
|
||||
const me = program.command("me").description("View your profile information");
|
||||
|
||||
me
|
||||
.command("skills")
|
||||
|
|
@ -86,4 +86,31 @@ export function registerMe(program: Command) {
|
|||
process.exitCode = 1;
|
||||
}
|
||||
});
|
||||
|
||||
me
|
||||
.command("namespaces")
|
||||
.description("List namespaces you have access to")
|
||||
.action(async () => {
|
||||
try {
|
||||
const token = await requireToken();
|
||||
const config = loadConfigFromProgram(program);
|
||||
const client = new ApiClient({ baseUrl: config.registry, token, debug: program.opts().debug });
|
||||
const namespaces = await client.get<{ slug: string; displayName: string; currentUserRole: string; status: string }[]>("/api/v1/me/namespaces");
|
||||
const isJson = program.opts().json;
|
||||
if (isJson) {
|
||||
console.log(JSON.stringify(namespaces, null, 2));
|
||||
} else {
|
||||
if (!namespaces || namespaces.length === 0) {
|
||||
console.log("No namespaces found.");
|
||||
return;
|
||||
}
|
||||
for (const ns of namespaces) {
|
||||
console.log(`${ns.slug} — ${ns.displayName} [${ns.currentUserRole}] (${ns.status})`);
|
||||
}
|
||||
}
|
||||
} catch (e: any) {
|
||||
error(`Failed to list namespaces: ${e.message}`);
|
||||
process.exitCode = 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue