feat(color): add --no-color flag (#5368)

Co-authored-by: pedrooot <pedromarting3@gmail.com>
Co-authored-by: Pepe Fagoaga <pepe@prowler.com>
This commit is contained in:
MrSecure
2024-10-28 06:23:21 -05:00
committed by GitHub
parent 0114d0462f
commit 172530153c
4 changed files with 25 additions and 0 deletions
+5
View File
@@ -24,6 +24,11 @@ Prowler can run without showing its banner:
```console
prowler <provider> -b/--no-banner
```
## Disable Colors
Prowler can run without showing colors:
```console
prowler <provider> --no-color
```
## Checks
Prowler has checks per provider, there are options related with them:
+4
View File
@@ -5,6 +5,7 @@ import sys
from os import environ
from colorama import Fore, Style
from colorama import init as colorama_init
from prowler.config.config import (
csv_file_suffix,
@@ -112,6 +113,9 @@ def prowler():
and not checks_folder
)
if args.no_color:
colorama_init(strip=True)
if not args.no_banner:
legend = args.verbose or getattr(args, "fixer", None)
print_banner(legend)
+6
View File
@@ -177,6 +177,12 @@ Detailed documentation at https://docs.prowler.com
common_outputs_parser.add_argument(
"--no-banner", "-b", action="store_true", help="Hide Prowler banner"
)
common_outputs_parser.add_argument(
"--no-color",
action="store_true",
help="Disable color codes in output",
)
common_outputs_parser.add_argument(
"--unix-timestamp",
action="store_true",
+10
View File
@@ -25,6 +25,7 @@ def mock_get_available_providers():
return ["aws", "azure", "gcp", "kubernetes"]
@pytest.mark.arg_parser
class Test_Parser:
def setup_method(self):
# We need this to mock the get_available_providers function call
@@ -52,6 +53,7 @@ class Test_Parser:
assert "output" in parsed.output_directory
assert not parsed.verbose
assert not parsed.no_banner
assert not parsed.no_color
assert not parsed.slack
assert not parsed.unix_timestamp
assert parsed.log_level == "CRITICAL"
@@ -100,6 +102,7 @@ class Test_Parser:
assert "output" in parsed.output_directory
assert not parsed.verbose
assert not parsed.no_banner
assert not parsed.no_color
assert not parsed.slack
assert not parsed.unix_timestamp
assert parsed.log_level == "CRITICAL"
@@ -140,6 +143,7 @@ class Test_Parser:
assert "output" in parsed.output_directory
assert not parsed.verbose
assert not parsed.no_banner
assert not parsed.no_color
assert not parsed.slack
assert not parsed.unix_timestamp
assert parsed.log_level == "CRITICAL"
@@ -175,6 +179,7 @@ class Test_Parser:
assert "output" in parsed.output_directory
assert not parsed.verbose
assert not parsed.no_banner
assert not parsed.no_color
assert not parsed.slack
assert not parsed.unix_timestamp
assert parsed.log_level == "CRITICAL"
@@ -355,6 +360,11 @@ class Test_Parser:
parsed = self.parser.parse(command)
assert parsed.no_banner
def test_root_parser_no_color_long(self):
command = [prowler_command, "--no-color"]
parsed = self.parser.parse(command)
assert parsed.no_color
def test_root_parser_slack(self):
command = [prowler_command, "--slack"]
parsed = self.parser.parse(command)