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 color option to CLI flags for output styling #23

Merged
merged 1 commit into from
Mar 31, 2024

Conversation

catatsuy
Copy link
Owner

This pull request mainly introduces colorized output to the CLI in the cli/cli.go file. It adds a new boolean field color to the CLI struct, a new command-line flag -color to control the color output, and modifies the matchesFilters function to return the matched regular expression. It also updates the filterProcess function to colorize the output line if the -color flag is set or if the output is a terminal. Additionally, a new function colorText is introduced to colorize the matched text, and a new test case is added in cli/cli_test.go to verify the color output.

Here are the major changes:

  • cli/cli.go:

    • Added a new boolean field color to the CLI struct to control the color output.
    • Added a new command-line flag -color in the parseFlags function.
    • Modified the filterProcess function to colorize the output line if the -color flag is set or if the output is a terminal.
    • Modified the matchesFilters function to return the matched regular expression.
    • Introduced a new function colorText to colorize the matched text.
  • cli/cli_test.go:

    • Added a new test case in TestRun_successProcess to verify the color output.

@catatsuy catatsuy merged commit b60f559 into main Mar 31, 2024
1 check passed
@catatsuy catatsuy deleted the feature_use_color_text branch March 31, 2024 04:51
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.

1 participant