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 colorized output to database, query, and shell commands #456

Merged
merged 4 commits into from
Dec 4, 2024
Merged

Conversation

ecooper
Copy link

@ecooper ecooper commented Dec 4, 2024

Problem

The database, query, and shell commands all output JSON. It's pretty printed, but does not support color. It's hard to scan as a result

Solution

For the database, query, and shell commands support colorized json output by default. This is done through the formatObjectForShell and formatFullErrorForShell helpers. The rest of this PR is largely just plumbing the color option through and updating tests.

Result

Query w/ color:
Screenshot 2024-12-03 at 4 06 25 PM

Color w/out color:
Screenshot 2024-12-03 at 4 06 38 PM

A different, fauna-like theme can be added in a follow-up PR.

Testing

Tests were updated to handle color changes.

Comment on lines +20 to +21
// We use stderr for messaging and there's no stdout output for a deleted database
logger.stderr(`Database '${argv.name}' was successfully deleted.`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Send messaging to stderr. Log messages, errors, and so on should all be sent to stderr. This means that when commands are piped together, these messages are displayed to the user and not fed into the next command.

This won't be a command that is piped, but the spirit remains.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. makes sense

@ecooper ecooper merged commit af18f6b into v3 Dec 4, 2024
4 checks passed
@ecooper ecooper deleted the v3-colorize branch December 4, 2024 16:58
@cleve-fauna cleve-fauna mentioned this pull request Dec 5, 2024
This was referenced Dec 6, 2024
@cleve-fauna cleve-fauna mentioned this pull request Dec 13, 2024
@wildemat wildemat mentioned this pull request Dec 18, 2024
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

Successfully merging this pull request may close these issues.

3 participants