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

UX tables get displayed along with json output on usage of --json flag #974

Closed
brunda-copado opened this issue Feb 26, 2024 · 2 comments
Closed

Comments

@brunda-copado
Copy link

I've built a command and Im displaying some data using the table component off Ux (from the library @salesforce/sf-plugins-core), but when I use the --json flag, the json response is output after the table. I'd expect only the json result and not the table to be printed.

To Reproduce
Steps to reproduce the behavior:

  1. Create a command with a Ux table printing some data on the stdout.
  2. use the command with the -- json flag

Expected behavior

I would expect the output to be just the json data, based on what Im returning in the command class instead of the table + json output.

Additional context
Versions used -
@oclif/core - 2.15.0
@salesforce/sf-plugins-core - 4.0.0

@mdonnalley
Copy link
Contributor

The ux module is not aware of the json flag and so you have to handle it yourself. The Command class has a jsonEnabled() method on it that will return true is json is enabled (either by the flag or env var). I would use that to determine if ux.table should be called.

if (!this.jsonEnabled()) ux.table()

@brunda-copado
Copy link
Author

Thanks a bunch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants