bfi-cli 0.1.13 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +25 -5
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -6773,8 +6773,20 @@ async function runWhoami(globalOpts) {
|
|
|
6773
6773
|
console.log(`\n用户名: ${displayName}`);
|
|
6774
6774
|
console.log(`用户ID: ${userId}`);
|
|
6775
6775
|
if (Array.isArray(namespaces) && namespaces.length > 0) {
|
|
6776
|
-
const
|
|
6777
|
-
|
|
6776
|
+
const displayWidth = (s) => {
|
|
6777
|
+
let w = 0;
|
|
6778
|
+
for (const ch of s) w += /[一-鿿 -〿-]/.test(ch) ? 2 : 1;
|
|
6779
|
+
return w;
|
|
6780
|
+
};
|
|
6781
|
+
const padToWidth = (s, w) => {
|
|
6782
|
+
let result = s;
|
|
6783
|
+
while (displayWidth(result) < w) result += " ";
|
|
6784
|
+
return result;
|
|
6785
|
+
};
|
|
6786
|
+
const slugs = namespaces.map((ns) => String(ns.slug || ""));
|
|
6787
|
+
const names = namespaces.map((ns) => String(ns.displayName || ""));
|
|
6788
|
+
const col1 = Math.max(...slugs.map((s) => displayWidth(s)), 4) + 1;
|
|
6789
|
+
const col2 = Math.max(...names.map((s) => displayWidth(s)), 4);
|
|
6778
6790
|
console.log(`\n命名空间 (${namespaces.length}):`);
|
|
6779
6791
|
for (const ns of namespaces) {
|
|
6780
6792
|
const role = ns.role || "MEMBER";
|
|
@@ -6784,9 +6796,9 @@ async function runWhoami(globalOpts) {
|
|
|
6784
6796
|
MEMBER: "成员",
|
|
6785
6797
|
VIEWER: "访客"
|
|
6786
6798
|
};
|
|
6787
|
-
const
|
|
6788
|
-
const
|
|
6789
|
-
console.log(`
|
|
6799
|
+
const s1 = padToWidth(`@${ns.slug}`, col1);
|
|
6800
|
+
const s2 = padToWidth(String(ns.displayName || ""), col2);
|
|
6801
|
+
console.log(` ${s1} ${s2} ${roleLabel[role] || role}`);
|
|
6790
6802
|
}
|
|
6791
6803
|
}
|
|
6792
6804
|
console.log();
|
|
@@ -8155,6 +8167,10 @@ async function dispatchSkillSubcommand(args, globalOpts) {
|
|
|
8155
8167
|
await runDocs(subArgs, globalOpts);
|
|
8156
8168
|
break;
|
|
8157
8169
|
case "auth":
|
|
8170
|
+
if (subArgs[0] === "logout") await runLogout();
|
|
8171
|
+
else if (subArgs[0] === "whoami") await runWhoami(globalOpts);
|
|
8172
|
+
else await runLogin(subArgs, globalOpts);
|
|
8173
|
+
break;
|
|
8158
8174
|
case "login":
|
|
8159
8175
|
await runLogin(subArgs, globalOpts);
|
|
8160
8176
|
break;
|
|
@@ -8228,6 +8244,10 @@ async function main() {
|
|
|
8228
8244
|
} catch {}
|
|
8229
8245
|
switch (command) {
|
|
8230
8246
|
case "auth":
|
|
8247
|
+
if (restArgs[0] === "logout") await runLogout();
|
|
8248
|
+
else if (restArgs[0] === "whoami") await runWhoami(globalOpts);
|
|
8249
|
+
else await runLogin(restArgs, globalOpts);
|
|
8250
|
+
break;
|
|
8231
8251
|
case "login":
|
|
8232
8252
|
await runLogin(restArgs, globalOpts);
|
|
8233
8253
|
break;
|