This commit is contained in:
parent
3b284484c2
commit
438884b270
2 changed files with 11 additions and 16 deletions
|
@ -5,35 +5,30 @@ export default class OutputHelper {
|
|||
public static GenerateOutput(response: IReturnResult, options: ICliOptions): string {
|
||||
const result = response.Result!;
|
||||
|
||||
let outputObject = {};
|
||||
let outputObject: any = {};
|
||||
|
||||
outputObject = { ...result };
|
||||
|
||||
if (options.queryMetadata) {
|
||||
this.AppendObject(outputObject, response.Query, "query");
|
||||
outputObject = { ...outputObject, ...response.Query }
|
||||
}
|
||||
|
||||
if (options.json) {
|
||||
return JSON.stringify(outputObject);
|
||||
}
|
||||
|
||||
return this.GetFriendlyObjectText(outputObject, "");
|
||||
return this.GetFriendlyObjectText(outputObject);
|
||||
}
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
private static GetFriendlyObjectText(object: any, output: string, prefix: string = ""): string {
|
||||
for (const key in object) {
|
||||
if (typeof(object[key]) == "object")
|
||||
return this.GetFriendlyObjectText(object[key], output, `${key}.`);
|
||||
private static GetFriendlyObjectText(object: any): string {
|
||||
let output = "";
|
||||
|
||||
output += `${prefix}${key} = ${object[key]}\n`;
|
||||
for (const key in object) {
|
||||
output += `${key} = ${object[key]}\n`;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
private static AppendObject(a: any, b: any, target: string): any {
|
||||
a[target] = { ...b };
|
||||
}
|
||||
/* eslint-enable @typescript-eslint/no-explicit-any */
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue