From 705e04bbb57ce7ffac423aa9067ac2070c2bd8da Mon Sep 17 00:00:00 2001 From: cyl19970726 <15258378443@163.com> Date: Wed, 1 Mar 2023 15:13:52 +0800 Subject: [PATCH] add new commander --- src/git3/actions.ts | 4 ++-- src/git3/index.ts | 28 +++++++++++++++++++++------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/git3/actions.ts b/src/git3/actions.ts index e92adf3..2abdd9c 100644 --- a/src/git3/actions.ts +++ b/src/git3/actions.ts @@ -61,7 +61,7 @@ export const HubMemberActions = [ name: 'role', message: 'add contributor or manager into hub', choices: [ - 'contribotor', + 'contributor', 'manager', ], }, @@ -74,7 +74,7 @@ export const HubGetMemberActions = [ message: 'get members corresponding to the role', choices: [ 'admin', - 'contribotor', + 'contributor', 'manager', ], }, diff --git a/src/git3/index.ts b/src/git3/index.ts index 1a36638..288c7fb 100644 --- a/src/git3/index.ts +++ b/src/git3/index.ts @@ -242,14 +242,18 @@ hub let protocol = await parseGit3URI(hub, { ignoreProtocolHeader: true, skipRepoName: true }) let answers = await inquirer.prompt(HubGetMemberActions) let role:string = "0x0000000000000000000000000000000000000000000000000000000000000000"; - switch (answers.role) { - case "admin": - role = "0x0000000000000000000000000000000000000000000000000000000000000000" - case "manager": - role = "0x0000000000000000000000000000000000000000000000000000000000000001" - case "contributor": - role = "0x0000000000000000000000000000000000000000000000000000000000000002" + + if (answers.role == "admin") { + role = "0x0000000000000000000000000000000000000000000000000000000000000000" + }else if (answers.role == "manager") { + role = "0x0000000000000000000000000000000000000000000000000000000000000001" + }else if (answers.role == "contributor") { + role = "0x0000000000000000000000000000000000000000000000000000000000000002" + }else { + throw new Error(`Invalid role ${answers.role}`) } + + console.error(`role:${role}`) let members = await protocol.hub.getMembersByRole(role) console.error(`${answers.role} : ${members}`) @@ -388,6 +392,16 @@ hub // =============================Repo Commands=================================== +repo + .command("list") + .argument("", "hub_name.NS or hub_address:chain_id") + .description("get all members from hub") + .action(async (hub) => { + let protocol = await parseGit3URI(hub, { ignoreProtocolHeader: true, skipRepoName: true }) + let repos = await protocol.hub.repoList() + console.error(`repos : ${repos}`) + }) + repo .command("create") .argument("", "ex: git3.w3q/repo_name or hub_addr:chainid/repo_name")