@freelog-cli/cli2 0.5.4 → 0.5.5
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/bin/index.js +142 -101
- package/dist/bin/index.js.map +1 -1
- package/dist/docs/01-/345/277/253/351/200/237/344/270/212/346/211/213.md +2 -0
- package/dist/docs/05-/350/265/204/346/272/220/347/256/241/347/220/206.md +2 -2
- package/dist/docs/10-/345/221/275/344/273/244/345/217/202/350/200/203.md +6 -6
- package/package.json +1 -1
package/dist/bin/index.js
CHANGED
|
@@ -25006,13 +25006,18 @@ function supportsResourceSubject(subjectType) {
|
|
|
25006
25006
|
function hasChildren(node) {
|
|
25007
25007
|
return Array.isArray(node.children) && node.children.length > 0;
|
|
25008
25008
|
}
|
|
25009
|
-
function flattenLeaves(nodes2, acc = []) {
|
|
25009
|
+
function flattenLeaves(nodes2, ancestors = [], acc = []) {
|
|
25010
25010
|
for (const node of nodes2) {
|
|
25011
|
+
const path20 = [...ancestors, node];
|
|
25011
25012
|
if (hasChildren(node)) {
|
|
25012
|
-
flattenLeaves(node.children, acc);
|
|
25013
|
+
flattenLeaves(node.children, path20, acc);
|
|
25013
25014
|
}
|
|
25014
25015
|
if (isEnabledResourceLeafCandidate(node)) {
|
|
25015
|
-
|
|
25016
|
+
const names = path20.map((item) => item.name.trim());
|
|
25017
|
+
if (names.some((name) => !name)) {
|
|
25018
|
+
throw new CliError("\u5E73\u53F0\u7C7B\u578B\u94FE\u5B58\u5728\u7F3A\u5931\u540D\u79F0\uFF0C\u65E0\u6CD5\u5C55\u793A\u5B8C\u6574\u5C42\u7EA7", "TYPE_HIERARCHY_INVALID");
|
|
25019
|
+
}
|
|
25020
|
+
acc.push({ ...node, nameChain: names.join(" / ") });
|
|
25016
25021
|
}
|
|
25017
25022
|
}
|
|
25018
25023
|
return acc;
|
|
@@ -25050,12 +25055,30 @@ async function listLeafTypes(apis = {}) {
|
|
|
25050
25055
|
async function searchLeafTypes(keyword, apis = {}) {
|
|
25051
25056
|
assertPlatformAllowed();
|
|
25052
25057
|
const request2 = apis.searchLeaves ?? ((params) => service_API_default.Resource.ListSimpleByParentCode(params));
|
|
25053
|
-
|
|
25054
|
-
|
|
25055
|
-
|
|
25056
|
-
|
|
25057
|
-
|
|
25058
|
-
|
|
25058
|
+
const [tree, response] = await Promise.all([
|
|
25059
|
+
resourceTypeTree(apis),
|
|
25060
|
+
request2({
|
|
25061
|
+
category: 1,
|
|
25062
|
+
nameChain: keyword,
|
|
25063
|
+
isTerminate: true,
|
|
25064
|
+
status: 1,
|
|
25065
|
+
subjectType: 1
|
|
25066
|
+
})
|
|
25067
|
+
]);
|
|
25068
|
+
const codes = /* @__PURE__ */ new Set();
|
|
25069
|
+
return unwrapList(response).flatMap((item) => {
|
|
25070
|
+
if (!item.code || codes.has(item.code)) return [];
|
|
25071
|
+
codes.add(item.code);
|
|
25072
|
+
const path20 = findTypePath(tree, item.code);
|
|
25073
|
+
if (!path20) return [];
|
|
25074
|
+
const leaf = path20[path20.length - 1];
|
|
25075
|
+
if (!isEnabledResourceLeafCandidate(leaf)) return [];
|
|
25076
|
+
const names = path20.map((node) => node.name.trim());
|
|
25077
|
+
if (names.some((name) => !name)) {
|
|
25078
|
+
throw new CliError("\u5E73\u53F0\u7C7B\u578B\u94FE\u5B58\u5728\u7F3A\u5931\u540D\u79F0\uFF0C\u65E0\u6CD5\u5C55\u793A\u5B8C\u6574\u5C42\u7EA7", "TYPE_HIERARCHY_INVALID");
|
|
25079
|
+
}
|
|
25080
|
+
return [{ ...leaf, nameChain: names.join(" / ") }];
|
|
25081
|
+
});
|
|
25059
25082
|
}
|
|
25060
25083
|
async function getTypeInfo(code, apis = {}) {
|
|
25061
25084
|
const normalized = code.trim();
|
|
@@ -25129,12 +25152,35 @@ async function chooseLeafType(apis = {}) {
|
|
|
25129
25152
|
}
|
|
25130
25153
|
throw new CliError("\u5DF2\u53D6\u6D88\u8D44\u6E90\u7C7B\u578B\u9009\u62E9", "TYPE_PICK_CANCELLED");
|
|
25131
25154
|
}
|
|
25155
|
+
var TYPE_LIST_PAGE_SIZE = 50;
|
|
25156
|
+
function typeListPage(items, page) {
|
|
25157
|
+
const pageCount = Math.max(1, Math.ceil(items.length / TYPE_LIST_PAGE_SIZE));
|
|
25158
|
+
if (!Number.isInteger(page) || page < 1 || page > pageCount) {
|
|
25159
|
+
throw new CliError(`\u7C7B\u578B\u9875\u7801\u8D85\u51FA\u8303\u56F4\uFF0C\u5F53\u524D\u5171 ${pageCount} \u9875`, "TYPE_LIST_PAGE");
|
|
25160
|
+
}
|
|
25161
|
+
return {
|
|
25162
|
+
page,
|
|
25163
|
+
pageCount,
|
|
25164
|
+
total: items.length,
|
|
25165
|
+
hasPrevious: page > 1,
|
|
25166
|
+
hasNext: page < pageCount,
|
|
25167
|
+
items: items.slice((page - 1) * TYPE_LIST_PAGE_SIZE, page * TYPE_LIST_PAGE_SIZE)
|
|
25168
|
+
};
|
|
25169
|
+
}
|
|
25132
25170
|
function formatTypeList(items) {
|
|
25133
25171
|
return items.map((item) => `${item.code} ${item.nameChain ?? item.name}`).join("\n");
|
|
25134
25172
|
}
|
|
25135
|
-
function
|
|
25173
|
+
function formatTypeListPage(page) {
|
|
25174
|
+
const header = `\u7B2C ${page.page}/${page.pageCount} \u9875\uFF0C\u5171 ${page.total} \u4E2A\u53EF\u7528\u6700\u7EC8\u53F6\u5B50\u7C7B\u578B`;
|
|
25175
|
+
const rows = formatTypeList(page.items);
|
|
25176
|
+
return rows ? `${header}
|
|
25177
|
+
${rows}` : `${header}
|
|
25178
|
+
\u6CA1\u6709\u5339\u914D\u7684\u542F\u7528\u6700\u7EC8\u53F6\u5B50\u7C7B\u578B`;
|
|
25179
|
+
}
|
|
25180
|
+
function formatTypeInfo(item, hierarchy) {
|
|
25136
25181
|
const optionalConfig = supportsOptionalConfig(item) ? "\u652F\u6301" : "\u4E0D\u652F\u6301";
|
|
25137
|
-
|
|
25182
|
+
const label = hierarchy?.join(" / ") || item.nameChain || item.name;
|
|
25183
|
+
return `${item.code} ${label} \u53EF\u9009\u914D\u7F6E\uFF1A${optionalConfig}`;
|
|
25138
25184
|
}
|
|
25139
25185
|
|
|
25140
25186
|
// src/domain/version/zip.ts
|
|
@@ -25760,7 +25806,7 @@ import { confirm, input } from "@inquirer/prompts";
|
|
|
25760
25806
|
import { Command as Command6 } from "commander";
|
|
25761
25807
|
|
|
25762
25808
|
// src/domain/policy/list.ts
|
|
25763
|
-
var
|
|
25809
|
+
var POLICY_TEMPLATE_PAGE_SIZE = 20;
|
|
25764
25810
|
function infoApi(apis) {
|
|
25765
25811
|
return apis?.info ?? ((params) => service_API_default.Resource.info(params));
|
|
25766
25812
|
}
|
|
@@ -25879,13 +25925,6 @@ async function applyPolicyTemplate(input2) {
|
|
|
25879
25925
|
const policyText = compiledContract(await request2({ _id: template.id, fillArgs: template.fillArgs }));
|
|
25880
25926
|
await applyPolicy({ ...input2, policyText });
|
|
25881
25927
|
}
|
|
25882
|
-
function positiveInteger(value, fallback, name, max) {
|
|
25883
|
-
const actual = value ?? fallback;
|
|
25884
|
-
if (!Number.isInteger(actual) || actual < 1 || actual > max) {
|
|
25885
|
-
throw new CliError(`${name} \u5FC5\u987B\u662F 1\u2013${max} \u7684\u6574\u6570`, "POLICY_TEMPLATE_PAGE");
|
|
25886
|
-
}
|
|
25887
|
-
return actual;
|
|
25888
|
-
}
|
|
25889
25928
|
async function getPolicyList(input2) {
|
|
25890
25929
|
const context = await loadPolicyContext(input2);
|
|
25891
25930
|
const typeHierarchy = await getTypeHierarchy(context.typeCode, input2.apis);
|
|
@@ -25894,46 +25933,40 @@ async function getPolicyList(input2) {
|
|
|
25894
25933
|
policies: [...context.policies].sort((a, b) => b.status - a.status || a.policyName.localeCompare(b.policyName))
|
|
25895
25934
|
};
|
|
25896
25935
|
}
|
|
25897
|
-
function
|
|
25898
|
-
const
|
|
25936
|
+
function formatPolicyList(list2) {
|
|
25937
|
+
const header = [
|
|
25938
|
+
`\u8D44\u6E90\u7C7B\u578B\uFF1A${list2.typeHierarchy.join(" / ")}`,
|
|
25939
|
+
`\u5171 ${list2.policies.length} \u6761\u6388\u6743\u7B56\u7565`
|
|
25940
|
+
];
|
|
25941
|
+
if (list2.policies.length === 0) return [...header, "\u8FD8\u6CA1\u6709\u6388\u6743\u7B56\u7565"].join("\n");
|
|
25942
|
+
return [
|
|
25943
|
+
...header,
|
|
25944
|
+
...list2.policies.map((item) => `${item.policyId} ${item.policyName} ${item.status === 1 ? "on" : "off"}`)
|
|
25945
|
+
].join("\n");
|
|
25946
|
+
}
|
|
25947
|
+
function policyTemplatePage(templates, page) {
|
|
25948
|
+
const pageCount = Math.max(1, Math.ceil(templates.length / POLICY_TEMPLATE_PAGE_SIZE));
|
|
25899
25949
|
if (!Number.isInteger(page) || page < 1 || page > pageCount) {
|
|
25900
|
-
throw new CliError(`\u7B56\u7565\u9875\u7801\u8D85\u51FA\u8303\u56F4\uFF0C\u5F53\u524D\u5171 ${pageCount} \u9875`, "
|
|
25950
|
+
throw new CliError(`\u7B56\u7565\u6A21\u677F\u9875\u7801\u8D85\u51FA\u8303\u56F4\uFF0C\u5F53\u524D\u5171 ${pageCount} \u9875`, "POLICY_TEMPLATE_PAGE");
|
|
25901
25951
|
}
|
|
25902
25952
|
return {
|
|
25903
|
-
...list2,
|
|
25904
25953
|
page,
|
|
25905
25954
|
pageCount,
|
|
25906
|
-
total:
|
|
25955
|
+
total: templates.length,
|
|
25907
25956
|
hasPrevious: page > 1,
|
|
25908
25957
|
hasNext: page < pageCount,
|
|
25909
|
-
items:
|
|
25958
|
+
items: templates.slice((page - 1) * POLICY_TEMPLATE_PAGE_SIZE, page * POLICY_TEMPLATE_PAGE_SIZE)
|
|
25910
25959
|
};
|
|
25911
25960
|
}
|
|
25912
|
-
function
|
|
25913
|
-
const header =
|
|
25914
|
-
|
|
25915
|
-
|
|
25916
|
-
];
|
|
25917
|
-
if (page.items.length === 0) return [...header, "\u8FD8\u6CA1\u6709\u6388\u6743\u7B56\u7565"].join("\n");
|
|
25961
|
+
function formatPolicyTemplatePage(page) {
|
|
25962
|
+
const header = `\u7B2C ${page.page}/${page.pageCount} \u9875\uFF0C\u5171 ${page.total} \u4E2A\u6388\u6743\u7B56\u7565\u6A21\u677F`;
|
|
25963
|
+
if (page.items.length === 0) return `${header}
|
|
25964
|
+
\u6CA1\u6709\u53EF\u7528\u6388\u6743\u7B56\u7565\u6A21\u677F`;
|
|
25918
25965
|
return [
|
|
25919
|
-
|
|
25920
|
-
...page.items.map((item) =>
|
|
25966
|
+
header,
|
|
25967
|
+
...page.items.map((item) => [item.id, item.name, item.summary].filter(Boolean).join(" "))
|
|
25921
25968
|
].join("\n");
|
|
25922
25969
|
}
|
|
25923
|
-
async function listPolicyTemplates(input2) {
|
|
25924
|
-
const page = positiveInteger(input2.page, 1, "--page", Number.MAX_SAFE_INTEGER);
|
|
25925
|
-
const pageSize2 = positiveInteger(input2.pageSize, 20, "--page-size", 100);
|
|
25926
|
-
const templates = await getPolicyTemplates(input2);
|
|
25927
|
-
const pageCount = Math.max(1, Math.ceil(templates.length / pageSize2));
|
|
25928
|
-
if (page > pageCount) {
|
|
25929
|
-
throw new CliError(`--page \u8D85\u51FA\u8303\u56F4\uFF0C\u5F53\u524D\u5171 ${pageCount} \u9875`, "POLICY_TEMPLATE_PAGE");
|
|
25930
|
-
}
|
|
25931
|
-
const rows = templates.slice((page - 1) * pageSize2, page * pageSize2).map((item) => [item.id, item.name, item.summary].filter(Boolean).join(" "));
|
|
25932
|
-
const next = page < pageCount ? `
|
|
25933
|
-
\u4E0B\u4E00\u9875\uFF1A--page ${page + 1}` : "";
|
|
25934
|
-
return `\u7B2C ${page}/${pageCount} \u9875\uFF0C\u5171 ${templates.length} \u6761${rows.length ? `
|
|
25935
|
-
${rows.join("\n")}` : ""}${next}`;
|
|
25936
|
-
}
|
|
25937
25970
|
function assertPolicyInput(context, policyName, policyText) {
|
|
25938
25971
|
const name = policyName.trim();
|
|
25939
25972
|
const text = policyText.trim();
|
|
@@ -26013,39 +26046,18 @@ function createPolicyApplyCommand() {
|
|
|
26013
26046
|
|
|
26014
26047
|
// src/commands/policy/list.ts
|
|
26015
26048
|
import { Command as Command7 } from "commander";
|
|
26016
|
-
async function showPolicyPages(pageFor) {
|
|
26017
|
-
let page = 1;
|
|
26018
|
-
while (true) {
|
|
26019
|
-
const current = pageFor(page);
|
|
26020
|
-
console.log(formatPolicyListPage(current));
|
|
26021
|
-
if (!current.hasPrevious && !current.hasNext) return;
|
|
26022
|
-
if (!isInteractive()) {
|
|
26023
|
-
if (current.hasNext) {
|
|
26024
|
-
console.log(`\u8FD8\u6709 ${current.total - current.page * POLICY_LIST_PAGE_SIZE} \u6761\u7B56\u7565\uFF1B\u8BF7\u5728\u4EA4\u4E92\u7EC8\u7AEF\u8FD0\u884C policy list \u67E5\u770B\u540E\u7EED\u9875`);
|
|
26025
|
-
}
|
|
26026
|
-
return;
|
|
26027
|
-
}
|
|
26028
|
-
const action = await selectQuestion("\u6388\u6743\u7B56\u7565\u5217\u8868", [
|
|
26029
|
-
...current.hasPrevious ? [{ name: "\u4E0A\u4E00\u9875", value: "__previous__" }] : [],
|
|
26030
|
-
...current.hasNext ? [{ name: "\u4E0B\u4E00\u9875", value: "__next__" }] : [],
|
|
26031
|
-
{ name: "\u9000\u51FA", value: "__exit__" }
|
|
26032
|
-
]);
|
|
26033
|
-
if (action === "__exit__") return;
|
|
26034
|
-
page += action === "__next__" ? 1 : -1;
|
|
26035
|
-
}
|
|
26036
|
-
}
|
|
26037
26049
|
function createPolicyListCommand() {
|
|
26038
26050
|
const command = addSharedOptions(new Command7("list"));
|
|
26039
26051
|
command.description(
|
|
26040
26052
|
// i18n: cli.command.policy.list.description
|
|
26041
|
-
"\u770B\
|
|
26053
|
+
"\u67E5\u770B\u5F53\u524D\u8D44\u6E90\u7684\u5168\u90E8\u6388\u6743\u7B56\u7565\u53CA\u8D44\u6E90\u7C7B\u578B\u5C42\u7EA7"
|
|
26042
26054
|
).action(async function() {
|
|
26043
26055
|
const shared = readSharedOptions(this);
|
|
26044
26056
|
const list2 = await getPolicyList({
|
|
26045
26057
|
cwd: resolveCwd(shared.cwd),
|
|
26046
26058
|
file: shared.file
|
|
26047
26059
|
});
|
|
26048
|
-
|
|
26060
|
+
console.log(formatPolicyList(list2));
|
|
26049
26061
|
});
|
|
26050
26062
|
return command;
|
|
26051
26063
|
}
|
|
@@ -26067,22 +26079,39 @@ function createPolicySetCommand() {
|
|
|
26067
26079
|
}
|
|
26068
26080
|
|
|
26069
26081
|
// src/commands/policy/template.ts
|
|
26070
|
-
import { confirm as confirm3
|
|
26082
|
+
import { confirm as confirm3 } from "@inquirer/prompts";
|
|
26071
26083
|
import { Command as Command9 } from "commander";
|
|
26084
|
+
async function showTemplatePages(templates) {
|
|
26085
|
+
let page = 1;
|
|
26086
|
+
while (true) {
|
|
26087
|
+
const current = policyTemplatePage(templates, page);
|
|
26088
|
+
console.log(formatPolicyTemplatePage(current));
|
|
26089
|
+
if (!current.hasPrevious && !current.hasNext) return;
|
|
26090
|
+
if (!isInteractive()) {
|
|
26091
|
+
if (current.hasNext) {
|
|
26092
|
+
console.log(`\u8FD8\u6709 ${current.total - current.page * POLICY_TEMPLATE_PAGE_SIZE} \u4E2A\u6388\u6743\u7B56\u7565\u6A21\u677F\uFF1B\u8BF7\u5728\u4EA4\u4E92\u7EC8\u7AEF\u8FD0\u884C policy template list \u67E5\u770B\u540E\u7EED\u9875`);
|
|
26093
|
+
}
|
|
26094
|
+
return;
|
|
26095
|
+
}
|
|
26096
|
+
const action = await selectQuestion("\u6388\u6743\u7B56\u7565\u6A21\u677F\u5217\u8868", [
|
|
26097
|
+
...current.hasPrevious ? [{ name: "\u4E0A\u4E00\u9875", value: "__previous__" }] : [],
|
|
26098
|
+
...current.hasNext ? [{ name: "\u4E0B\u4E00\u9875", value: "__next__" }] : [],
|
|
26099
|
+
{ name: "\u9000\u51FA", value: "__exit__" }
|
|
26100
|
+
]);
|
|
26101
|
+
if (action === "__exit__") return;
|
|
26102
|
+
page += action === "__next__" ? 1 : -1;
|
|
26103
|
+
}
|
|
26104
|
+
}
|
|
26072
26105
|
async function chooseTemplate(templates) {
|
|
26073
|
-
let page =
|
|
26074
|
-
const pageSize2 = 20;
|
|
26106
|
+
let page = 1;
|
|
26075
26107
|
while (true) {
|
|
26076
|
-
const
|
|
26077
|
-
const value = await
|
|
26078
|
-
|
|
26079
|
-
|
|
26080
|
-
|
|
26081
|
-
|
|
26082
|
-
|
|
26083
|
-
{ name: "\u53D6\u6D88", value: "__cancel__" }
|
|
26084
|
-
]
|
|
26085
|
-
});
|
|
26108
|
+
const current = policyTemplatePage(templates, page);
|
|
26109
|
+
const value = await selectQuestion(`\u8BF7\u9009\u62E9\u6388\u6743\u7B56\u7565\u6A21\u677F\uFF08\u7B2C ${current.page}/${current.pageCount} \u9875\uFF09`, [
|
|
26110
|
+
...current.items.map((item) => ({ name: `${item.name} (${item.id})${item.summary ? ` \u2014 ${item.summary}` : ""}`, value: item.id })),
|
|
26111
|
+
...current.hasPrevious ? [{ name: "\u4E0A\u4E00\u9875", value: "__previous__" }] : [],
|
|
26112
|
+
...current.hasNext ? [{ name: "\u4E0B\u4E00\u9875", value: "__next__" }] : [],
|
|
26113
|
+
{ name: "\u53D6\u6D88", value: "__cancel__" }
|
|
26114
|
+
]);
|
|
26086
26115
|
if (value === "__previous__") {
|
|
26087
26116
|
page -= 1;
|
|
26088
26117
|
continue;
|
|
@@ -26097,9 +26126,9 @@ async function chooseTemplate(templates) {
|
|
|
26097
26126
|
}
|
|
26098
26127
|
function createPolicyTemplateCommand() {
|
|
26099
26128
|
const template = addSharedOptions(new Command9("template")).description("\u6388\u6743\u7B56\u7565\u6A21\u677F");
|
|
26100
|
-
addSharedOptions(template.command("list")).description("\u5217\u5F53\u524D\u6A21\u677F\u5217\u8868
|
|
26129
|
+
addSharedOptions(template.command("list")).description("\u5217\u5F53\u524D\u6A21\u677F\u5217\u8868\uFF08\u6BCF\u9875 20 \u6761\uFF09").action(async function() {
|
|
26101
26130
|
const shared = readSharedOptions(this);
|
|
26102
|
-
|
|
26131
|
+
await showTemplatePages(await getPolicyTemplates({ cwd: resolveCwd(shared.cwd), file: shared.file }));
|
|
26103
26132
|
});
|
|
26104
26133
|
addSharedOptions(template.command("apply")).description("\u5E94\u7528\u5F53\u524D\u7C7B\u578B\u7684\u4E00\u6761\u6A21\u677F\u5E76\u542F\u7528").argument("[templateId]", "\u6A21\u677F\u7F16\u53F7").option("--name <name>", "\u7B56\u7565\u540D").action(async function(templateId, options) {
|
|
26105
26134
|
const shared = readSharedOptions(this);
|
|
@@ -26634,22 +26663,40 @@ function requireTypeAuth(command) {
|
|
|
26634
26663
|
const shared = readSharedOptions(command);
|
|
26635
26664
|
requireAuth({ cwd: resolveCwd(shared.cwd) });
|
|
26636
26665
|
}
|
|
26666
|
+
async function showTypePages(items, commandText) {
|
|
26667
|
+
let page = 1;
|
|
26668
|
+
while (true) {
|
|
26669
|
+
const current = typeListPage(items, page);
|
|
26670
|
+
console.log(formatTypeListPage(current));
|
|
26671
|
+
if (!current.hasPrevious && !current.hasNext) return;
|
|
26672
|
+
if (!isInteractive()) {
|
|
26673
|
+
if (current.hasNext) {
|
|
26674
|
+
console.log(`\u8FD8\u6709 ${current.total - current.page * TYPE_LIST_PAGE_SIZE} \u4E2A\u8D44\u6E90\u7C7B\u578B\uFF1B\u8BF7\u5728\u4EA4\u4E92\u7EC8\u7AEF\u8FD0\u884C ${commandText} \u67E5\u770B\u540E\u7EED\u9875`);
|
|
26675
|
+
}
|
|
26676
|
+
return;
|
|
26677
|
+
}
|
|
26678
|
+
const action = await selectQuestion("\u8D44\u6E90\u7C7B\u578B\u5217\u8868", [
|
|
26679
|
+
...current.hasPrevious ? [{ name: "\u4E0A\u4E00\u9875", value: "__previous__" }] : [],
|
|
26680
|
+
...current.hasNext ? [{ name: "\u4E0B\u4E00\u9875", value: "__next__" }] : [],
|
|
26681
|
+
{ name: "\u9000\u51FA", value: "__exit__" }
|
|
26682
|
+
]);
|
|
26683
|
+
if (action === "__exit__") return;
|
|
26684
|
+
page += action === "__next__" ? 1 : -1;
|
|
26685
|
+
}
|
|
26686
|
+
}
|
|
26637
26687
|
function createTypeCommand() {
|
|
26638
26688
|
const type = addSharedOptions(new Command14("type"));
|
|
26639
26689
|
type.description(
|
|
26640
26690
|
// i18n: cli.command.type.description
|
|
26641
|
-
"\u67E5\u8BE2\u53F6\u5B50\u7C7B\u578B"
|
|
26691
|
+
"\u67E5\u8BE2\u53EF\u9009\u6700\u7EC8\u53F6\u5B50\u7C7B\u578B"
|
|
26642
26692
|
);
|
|
26643
26693
|
addSharedOptions(type.command("list")).description(
|
|
26644
26694
|
// i18n: cli.command.type.list.description
|
|
26645
|
-
"\u5217\u51FA\u53F6\u5B50\u7C7B\u578B"
|
|
26695
|
+
"\u5217\u51FA\u6700\u7EC8\u53F6\u5B50\u7C7B\u578B\u7684\u5B8C\u6574\u5C42\u7EA7\u8DEF\u5F84"
|
|
26646
26696
|
).action(async function() {
|
|
26647
26697
|
requireTypeAuth(this);
|
|
26648
26698
|
const items = await listLeafTypes();
|
|
26649
|
-
|
|
26650
|
-
if (text) {
|
|
26651
|
-
console.log(text);
|
|
26652
|
-
}
|
|
26699
|
+
await showTypePages(items, "type list");
|
|
26653
26700
|
});
|
|
26654
26701
|
addSharedOptions(type.command("search")).description(
|
|
26655
26702
|
// i18n: cli.command.type.search.description
|
|
@@ -26661,10 +26708,7 @@ function createTypeCommand() {
|
|
|
26661
26708
|
).action(async function(keyword) {
|
|
26662
26709
|
requireTypeAuth(this);
|
|
26663
26710
|
const items = await searchLeafTypes(keyword ?? "");
|
|
26664
|
-
|
|
26665
|
-
if (text) {
|
|
26666
|
-
console.log(text);
|
|
26667
|
-
}
|
|
26711
|
+
await showTypePages(items, `type search ${keyword ?? ""}`.trim());
|
|
26668
26712
|
});
|
|
26669
26713
|
addSharedOptions(type.command("pick")).description(
|
|
26670
26714
|
// i18n: cli.command.type.pick.description
|
|
@@ -26677,14 +26721,11 @@ function createTypeCommand() {
|
|
|
26677
26721
|
requireTypeAuth(this);
|
|
26678
26722
|
if (!options.type) {
|
|
26679
26723
|
const items = await listLeafTypes();
|
|
26680
|
-
|
|
26681
|
-
if (text) {
|
|
26682
|
-
console.log(text);
|
|
26683
|
-
}
|
|
26724
|
+
await showTypePages(items, "type pick");
|
|
26684
26725
|
return;
|
|
26685
26726
|
}
|
|
26686
26727
|
const info2 = await getTypeInfo(options.type);
|
|
26687
|
-
console.log(formatTypeInfo(info2));
|
|
26728
|
+
console.log(formatTypeInfo(info2, await getTypeHierarchy(info2.code)));
|
|
26688
26729
|
});
|
|
26689
26730
|
addSharedOptions(type.command("info")).description(
|
|
26690
26731
|
// i18n: cli.command.type.info.description
|
|
@@ -26699,7 +26740,7 @@ function createTypeCommand() {
|
|
|
26699
26740
|
throw new CliError("\u8BF7\u63D0\u4F9B\u7C7B\u578B\u7F16\u53F7", "TYPE_CODE_REQUIRED");
|
|
26700
26741
|
}
|
|
26701
26742
|
const info2 = await getTypeInfo(code);
|
|
26702
|
-
console.log(formatTypeInfo(info2));
|
|
26743
|
+
console.log(formatTypeInfo(info2, await getTypeHierarchy(info2.code)));
|
|
26703
26744
|
});
|
|
26704
26745
|
return type;
|
|
26705
26746
|
}
|