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 support for colorized output #347

Merged
merged 17 commits into from
Oct 1, 2020
Merged

Conversation

acc-jon
Copy link
Contributor

@acc-jon acc-jon commented Oct 1, 2020

Add a command-line option to specify whether output should be colored (default="auto"). In auto mode, colors will be enabled if the output will be written to a terminal. The coloring is applied after the output has been marshalled, to avoid corrupting any output data. Add --use-colors=false to force colors off.

Note that coloring is only applied to JSON and YAML output, because coloring XML is not helpful. XML is already too dense to read easily.

Default colors are built in, but are user configurable via a JSON file. Example in pkg/termcolor/color_patterns.json.sample. Enable the custom colors with an environment variable, TERRASCAN_COLORS_FILE=<absolute-path-to-color_patterns.json>

@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 1, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@codecov
Copy link

codecov bot commented Oct 1, 2020

Codecov Report

Merging #347 into master will increase coverage by 0.59%.
The diff coverage is 57.61%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #347      +/-   ##
==========================================
+ Coverage   61.45%   62.05%   +0.59%     
==========================================
  Files          57       61       +4     
  Lines        1069     1215     +146     
==========================================
+ Hits          657      754      +97     
- Misses        346      391      +45     
- Partials       66       70       +4     
Impacted Files Coverage Δ
pkg/cli/output_writer.go 0.00% <0.00%> (ø)
pkg/cli/scan.go 31.25% <5.00%> (-33.04%) ⬇️
pkg/cli/run.go 33.33% <25.00%> (-2.39%) ⬇️
pkg/termcolor/colorpatterns.go 40.47% <40.47%> (ø)
pkg/termcolor/termcolor.go 80.00% <80.00%> (ø)
pkg/termcolor/writer.go 100.00% <100.00%> (ø)
... and 4 more

Copy link
Contributor

@cesar-rodriguez cesar-rodriguez left a comment

Choose a reason for hiding this comment

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

Thanks!

@cesar-rodriguez cesar-rodriguez merged commit 556d333 into tenable:master Oct 1, 2020
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