Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flag for specifying "machine-friendly output" #9

Merged
merged 1 commit into from Jan 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/cli/options.ts
Expand Up @@ -30,6 +30,13 @@ export class InputOutputOptions extends Options implements IInputOutput {
})
public enableDebug = false;

@option({
name: "machine-friendly",
description: "Enable machine-friendly output",
toggle: true,
})
public machineFriendly = false;

public logError(error: any) {
console.error(error);
}
Expand All @@ -43,6 +50,8 @@ export class InputOutputOptions extends Options implements IInputOutput {
public logResult(result: any) {
if (typeof result === "string") {
console.log(result);
} else if (this.machineFriendly) {
console.log(JSON.stringify(result));
} else {
console.log(JSON.stringify(result, null, 2));
}
Expand Down