@robinmordasiewicz/f5xc-xcsh 2.0.13-2601051841 → 2.0.13-2601052351
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/index.js +195 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -46994,8 +46994,8 @@ function getLogoModeFromEnv(envPrefix) {
|
|
|
46994
46994
|
var CLI_NAME = "xcsh";
|
|
46995
46995
|
var CLI_FULL_NAME = "F5 Distributed Cloud Shell";
|
|
46996
46996
|
function getVersion() {
|
|
46997
|
-
if ("v2.0.13-
|
|
46998
|
-
return "v2.0.13-
|
|
46997
|
+
if ("v2.0.13-2601052351") {
|
|
46998
|
+
return "v2.0.13-2601052351";
|
|
46999
46999
|
}
|
|
47000
47000
|
if (process.env.XCSH_VERSION) {
|
|
47001
47001
|
return process.env.XCSH_VERSION;
|
|
@@ -47920,6 +47920,9 @@ function getValue(row, accessor) {
|
|
|
47920
47920
|
if (accessor === "labels") {
|
|
47921
47921
|
return formatLabelsValue(value);
|
|
47922
47922
|
}
|
|
47923
|
+
if (isComplexValue(value)) {
|
|
47924
|
+
return formatIndentedTree(value, 0, 4, 40).join("\n");
|
|
47925
|
+
}
|
|
47923
47926
|
return JSON.stringify(value);
|
|
47924
47927
|
}
|
|
47925
47928
|
return String(value);
|
|
@@ -47931,6 +47934,135 @@ function formatLabelsValue(labels) {
|
|
|
47931
47934
|
}
|
|
47932
47935
|
return `map[${entries.join(" ")}]`;
|
|
47933
47936
|
}
|
|
47937
|
+
function isComplexValue(value) {
|
|
47938
|
+
if (value === null || value === void 0) return false;
|
|
47939
|
+
if (typeof value !== "object") return false;
|
|
47940
|
+
if (Array.isArray(value)) {
|
|
47941
|
+
return value.some((item) => typeof item === "object" && item !== null);
|
|
47942
|
+
}
|
|
47943
|
+
const obj = value;
|
|
47944
|
+
const keys = Object.keys(obj);
|
|
47945
|
+
if (keys.length > 3) return true;
|
|
47946
|
+
return keys.some((k) => {
|
|
47947
|
+
const v = obj[k];
|
|
47948
|
+
return typeof v === "object" && v !== null;
|
|
47949
|
+
});
|
|
47950
|
+
}
|
|
47951
|
+
function formatIndentedTree(value, indent = 0, maxDepth = 6, maxWidth = 60) {
|
|
47952
|
+
const INDENT_SIZE = 2;
|
|
47953
|
+
const lines = [];
|
|
47954
|
+
if (value === null) {
|
|
47955
|
+
return ["null"];
|
|
47956
|
+
}
|
|
47957
|
+
if (value === void 0) {
|
|
47958
|
+
return [""];
|
|
47959
|
+
}
|
|
47960
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
47961
|
+
return [String(value)];
|
|
47962
|
+
}
|
|
47963
|
+
if (indent / INDENT_SIZE >= maxDepth) {
|
|
47964
|
+
const json = JSON.stringify(value);
|
|
47965
|
+
return json.length > maxWidth ? [json.slice(0, maxWidth - 3) + "..."] : [json];
|
|
47966
|
+
}
|
|
47967
|
+
if (Array.isArray(value)) {
|
|
47968
|
+
if (value.length === 0) {
|
|
47969
|
+
return ["[]"];
|
|
47970
|
+
}
|
|
47971
|
+
const isSimple = value.every(
|
|
47972
|
+
(v) => typeof v === "string" || typeof v === "number" || typeof v === "boolean" || v === null
|
|
47973
|
+
);
|
|
47974
|
+
if (isSimple && value.length <= 5) {
|
|
47975
|
+
const inline = `[${value.map((v) => v === null ? "null" : String(v)).join(", ")}]`;
|
|
47976
|
+
if (inline.length <= maxWidth) {
|
|
47977
|
+
return [inline];
|
|
47978
|
+
}
|
|
47979
|
+
}
|
|
47980
|
+
for (let i = 0; i < value.length; i++) {
|
|
47981
|
+
const item = value[i];
|
|
47982
|
+
const prefix = `[${i}]: `;
|
|
47983
|
+
if (typeof item === "object" && item !== null) {
|
|
47984
|
+
lines.push(prefix);
|
|
47985
|
+
const subLines = formatIndentedTree(
|
|
47986
|
+
item,
|
|
47987
|
+
indent + INDENT_SIZE,
|
|
47988
|
+
maxDepth,
|
|
47989
|
+
maxWidth
|
|
47990
|
+
);
|
|
47991
|
+
for (const subLine of subLines) {
|
|
47992
|
+
lines.push(" ".repeat(INDENT_SIZE) + subLine);
|
|
47993
|
+
}
|
|
47994
|
+
} else {
|
|
47995
|
+
const formatted = formatIndentedTree(
|
|
47996
|
+
item,
|
|
47997
|
+
indent,
|
|
47998
|
+
maxDepth,
|
|
47999
|
+
maxWidth
|
|
48000
|
+
);
|
|
48001
|
+
lines.push(prefix + formatted[0]);
|
|
48002
|
+
}
|
|
48003
|
+
}
|
|
48004
|
+
return lines;
|
|
48005
|
+
}
|
|
48006
|
+
if (typeof value === "object") {
|
|
48007
|
+
const obj = value;
|
|
48008
|
+
const keys = Object.keys(obj);
|
|
48009
|
+
if (keys.length === 0) {
|
|
48010
|
+
return ["{}"];
|
|
48011
|
+
}
|
|
48012
|
+
if (keys.length <= 2) {
|
|
48013
|
+
const allSimple = keys.every((k) => {
|
|
48014
|
+
const v = obj[k];
|
|
48015
|
+
return v === null || typeof v === "string" || typeof v === "number" || typeof v === "boolean" || typeof v === "object" && v !== null && Object.keys(v).length === 0;
|
|
48016
|
+
});
|
|
48017
|
+
if (allSimple) {
|
|
48018
|
+
const inline = keys.map((k) => {
|
|
48019
|
+
const v = obj[k];
|
|
48020
|
+
if (v === null) return `${k}: null`;
|
|
48021
|
+
if (typeof v === "object" && Object.keys(v).length === 0) {
|
|
48022
|
+
return Array.isArray(v) ? `${k}: []` : `${k}: {}`;
|
|
48023
|
+
}
|
|
48024
|
+
return `${k}: ${v}`;
|
|
48025
|
+
}).join(", ");
|
|
48026
|
+
if (inline.length <= maxWidth) {
|
|
48027
|
+
return [inline];
|
|
48028
|
+
}
|
|
48029
|
+
}
|
|
48030
|
+
}
|
|
48031
|
+
for (const key of keys) {
|
|
48032
|
+
const childValue = obj[key];
|
|
48033
|
+
if (typeof childValue === "object" && childValue !== null) {
|
|
48034
|
+
const childObj = childValue;
|
|
48035
|
+
const isEmpty = Array.isArray(childObj) ? childObj.length === 0 : Object.keys(childObj).length === 0;
|
|
48036
|
+
if (isEmpty) {
|
|
48037
|
+
lines.push(
|
|
48038
|
+
`${key}: ${Array.isArray(childObj) ? "[]" : "{}"}`
|
|
48039
|
+
);
|
|
48040
|
+
} else {
|
|
48041
|
+
lines.push(`${key}:`);
|
|
48042
|
+
const subLines = formatIndentedTree(
|
|
48043
|
+
childValue,
|
|
48044
|
+
indent + INDENT_SIZE,
|
|
48045
|
+
maxDepth,
|
|
48046
|
+
maxWidth
|
|
48047
|
+
);
|
|
48048
|
+
for (const subLine of subLines) {
|
|
48049
|
+
lines.push(" ".repeat(INDENT_SIZE) + subLine);
|
|
48050
|
+
}
|
|
48051
|
+
}
|
|
48052
|
+
} else {
|
|
48053
|
+
const formatted = formatIndentedTree(
|
|
48054
|
+
childValue,
|
|
48055
|
+
indent,
|
|
48056
|
+
maxDepth,
|
|
48057
|
+
maxWidth
|
|
48058
|
+
);
|
|
48059
|
+
lines.push(`${key}: ${formatted[0]}`);
|
|
48060
|
+
}
|
|
48061
|
+
}
|
|
48062
|
+
return lines;
|
|
48063
|
+
}
|
|
48064
|
+
return [String(value)];
|
|
48065
|
+
}
|
|
47934
48066
|
function calculateColumnWidths(columns, rows, maxTableWidth) {
|
|
47935
48067
|
const widths = columns.map((col) => {
|
|
47936
48068
|
let width = col.header.length;
|
|
@@ -48117,11 +48249,19 @@ function formatKeyValueBox(data, title, noColor = false, maxWidth) {
|
|
|
48117
48249
|
const contentLines = [];
|
|
48118
48250
|
for (const d of data) {
|
|
48119
48251
|
const paddedLabel = d.label.padEnd(maxLabelWidth);
|
|
48120
|
-
const wrappedValueLines = wrapText2(d.value, maxValueWidth);
|
|
48121
|
-
contentLines.push(`${paddedLabel}: ${wrappedValueLines[0] ?? ""}`);
|
|
48122
48252
|
const indent = " ".repeat(maxLabelWidth + 3);
|
|
48123
|
-
|
|
48124
|
-
|
|
48253
|
+
const valueLines = d.value.split("\n");
|
|
48254
|
+
let isFirstLine = true;
|
|
48255
|
+
for (const valueLine of valueLines) {
|
|
48256
|
+
const wrappedLines = wrapText2(valueLine, maxValueWidth);
|
|
48257
|
+
for (const wrappedLine of wrappedLines) {
|
|
48258
|
+
if (isFirstLine) {
|
|
48259
|
+
contentLines.push(`${paddedLabel}: ${wrappedLine}`);
|
|
48260
|
+
isFirstLine = false;
|
|
48261
|
+
} else {
|
|
48262
|
+
contentLines.push(`${indent}${wrappedLine}`);
|
|
48263
|
+
}
|
|
48264
|
+
}
|
|
48125
48265
|
}
|
|
48126
48266
|
}
|
|
48127
48267
|
const titleText = ` ${title} `;
|
|
@@ -48181,7 +48321,7 @@ function formatDetailValue(value) {
|
|
|
48181
48321
|
if (isSimple && value.length <= 5) {
|
|
48182
48322
|
return `[${value.join(", ")}]`;
|
|
48183
48323
|
}
|
|
48184
|
-
return
|
|
48324
|
+
return formatIndentedTree(value, 0, 6, 60).join("\n");
|
|
48185
48325
|
}
|
|
48186
48326
|
if (typeof value === "object") {
|
|
48187
48327
|
const obj = value;
|
|
@@ -48195,7 +48335,7 @@ function formatDetailValue(value) {
|
|
|
48195
48335
|
return keys.map((k) => `${k}: ${obj[k]}`).join(", ");
|
|
48196
48336
|
}
|
|
48197
48337
|
}
|
|
48198
|
-
return
|
|
48338
|
+
return formatIndentedTree(value, 0, 6, 60).join("\n");
|
|
48199
48339
|
}
|
|
48200
48340
|
return String(value);
|
|
48201
48341
|
}
|
|
@@ -151712,7 +151852,8 @@ var Completer = class {
|
|
|
151712
151852
|
if (parsed.isCompletingFlagValue && parsed.currentFlag) {
|
|
151713
151853
|
return await this.getFlagValueCompletions(
|
|
151714
151854
|
parsed.currentFlag,
|
|
151715
|
-
parsed.currentWord
|
|
151855
|
+
parsed.currentWord,
|
|
151856
|
+
parsed
|
|
151716
151857
|
);
|
|
151717
151858
|
}
|
|
151718
151859
|
if (parsed.isCompletingFlag) {
|
|
@@ -152211,10 +152352,24 @@ var Completer = class {
|
|
|
152211
152352
|
const allFlags = this.getActionFlagSuggestions(action);
|
|
152212
152353
|
return this.filterSuggestions(allFlags, prefix);
|
|
152213
152354
|
}
|
|
152355
|
+
/**
|
|
152356
|
+
* Extract a flag value from args array
|
|
152357
|
+
* @param args - Array of command arguments
|
|
152358
|
+
* @param flagNames - Flag names to look for (e.g., ["--namespace", "-ns"])
|
|
152359
|
+
* @returns The flag value or undefined if not found
|
|
152360
|
+
*/
|
|
152361
|
+
extractFlagValue(args, flagNames) {
|
|
152362
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
152363
|
+
if (flagNames.includes(args[i] ?? "")) {
|
|
152364
|
+
return args[i + 1];
|
|
152365
|
+
}
|
|
152366
|
+
}
|
|
152367
|
+
return void 0;
|
|
152368
|
+
}
|
|
152214
152369
|
/**
|
|
152215
152370
|
* Get flag value completions based on the flag being completed
|
|
152216
152371
|
*/
|
|
152217
|
-
async getFlagValueCompletions(flag, partial) {
|
|
152372
|
+
async getFlagValueCompletions(flag, partial, parsed) {
|
|
152218
152373
|
let valuePartial = partial;
|
|
152219
152374
|
if (partial.includes("=")) {
|
|
152220
152375
|
valuePartial = partial.slice(partial.indexOf("=") + 1);
|
|
@@ -152234,18 +152389,28 @@ var Completer = class {
|
|
|
152234
152389
|
case "-ns":
|
|
152235
152390
|
return this.completeNamespace(valuePartial);
|
|
152236
152391
|
case "--name":
|
|
152237
|
-
case "-n":
|
|
152238
|
-
if (this.session) {
|
|
152239
|
-
|
|
152240
|
-
|
|
152241
|
-
|
|
152242
|
-
|
|
152243
|
-
|
|
152244
|
-
|
|
152245
|
-
|
|
152246
|
-
|
|
152392
|
+
case "-n": {
|
|
152393
|
+
if (!this.session) {
|
|
152394
|
+
return [];
|
|
152395
|
+
}
|
|
152396
|
+
const resourceCtx = this.parseResourceContext(parsed);
|
|
152397
|
+
const navCtx = this.session.getContextPath();
|
|
152398
|
+
const resourceType = resourceCtx.resourceType || navCtx.domain || null;
|
|
152399
|
+
const nsFromFlag = this.extractFlagValue(parsed.args, [
|
|
152400
|
+
"--namespace",
|
|
152401
|
+
"-ns"
|
|
152402
|
+
]);
|
|
152403
|
+
const namespace = nsFromFlag || this.session.getNamespace();
|
|
152404
|
+
if (resourceType && namespace) {
|
|
152405
|
+
return this.completeResourceName(
|
|
152406
|
+
resourceType,
|
|
152407
|
+
resourceType,
|
|
152408
|
+
valuePartial,
|
|
152409
|
+
namespace
|
|
152410
|
+
);
|
|
152247
152411
|
}
|
|
152248
152412
|
return [];
|
|
152413
|
+
}
|
|
152249
152414
|
case "--limit":
|
|
152250
152415
|
return [
|
|
152251
152416
|
{
|
|
@@ -152306,8 +152471,8 @@ var Completer = class {
|
|
|
152306
152471
|
/**
|
|
152307
152472
|
* Complete resource names with caching
|
|
152308
152473
|
*/
|
|
152309
|
-
async completeResourceName(domain, _resourceType, partial) {
|
|
152310
|
-
const namespace = this.session?.getNamespace()
|
|
152474
|
+
async completeResourceName(domain, _resourceType, partial, namespaceOverride) {
|
|
152475
|
+
const namespace = namespaceOverride || this.session?.getNamespace() || "default";
|
|
152311
152476
|
const cacheKey = `${domain}:${namespace}`;
|
|
152312
152477
|
const names = await this.cache.getResourceNames(cacheKey, async () => {
|
|
152313
152478
|
const client = this.session?.getAPIClient();
|
|
@@ -152503,6 +152668,8 @@ var BUILTIN_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
152503
152668
|
"ctx",
|
|
152504
152669
|
"history",
|
|
152505
152670
|
"version",
|
|
152671
|
+
"--version",
|
|
152672
|
+
"-v",
|
|
152506
152673
|
"domains",
|
|
152507
152674
|
"whoami",
|
|
152508
152675
|
"refresh"
|
|
@@ -152543,7 +152710,12 @@ function parseCommand(input) {
|
|
|
152543
152710
|
const firstWord = trimmed.split(/\s+/)[0]?.toLowerCase() ?? "";
|
|
152544
152711
|
const normalizedFirst = firstWord.startsWith("/") ? firstWord.slice(1) : firstWord;
|
|
152545
152712
|
if (BUILTIN_COMMANDS.has(firstWord) || BUILTIN_COMMANDS.has(normalizedFirst)) {
|
|
152546
|
-
|
|
152713
|
+
let effectiveCommand = normalizedFirst;
|
|
152714
|
+
if (normalizedFirst === "--help" || normalizedFirst === "-h") {
|
|
152715
|
+
effectiveCommand = "help";
|
|
152716
|
+
} else if (normalizedFirst === "--version" || normalizedFirst === "-v") {
|
|
152717
|
+
effectiveCommand = "version";
|
|
152718
|
+
}
|
|
152547
152719
|
return {
|
|
152548
152720
|
raw: effectiveCommand,
|
|
152549
152721
|
isDirectNavigation: false,
|