From 99222db16300da8be75439f0ba8ee5db8c0ee341 Mon Sep 17 00:00:00 2001 From: Italo Maia Date: Tue, 18 Feb 2025 18:35:27 +0100 Subject: [PATCH] Adding --ansi to cli with support to the "never" value. Improves compatibility with SpringBoot3 compose plugin --- podman_compose.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/podman_compose.py b/podman_compose.py index 4da6c22..691fd88 100755 --- a/podman_compose.py +++ b/podman_compose.py @@ -2286,7 +2286,16 @@ class PodmanCompose: ) # pylint: disable=protected-access for cmd_parser in cmd._parse_args: # pylint: disable=protected-access cmd_parser(subparser) + self.global_args = parser.parse_args(argv) + + if self.global_args.ansi: + if self.global_args.ansi == "never": + self.global_args.no_ansi = True + # if an option is added but we don't know how to handle it, fail! + else: + raise ValueError(f"Unsupported --ansi value: {self.global_args.ansi}.") + if ( self.global_args.in_pod is not None and self.global_args.in_pod.lower() @@ -2387,9 +2396,16 @@ class PodmanCompose: action="append", default=[], ) + parser.add_argument( + "--ansi", + help="Controls when to print ANSI control characters.", + choices=["never"], + type=str, + default=None, + ) parser.add_argument( "--no-ansi", - help="Do not print ANSI control characters", + help="Do not print ANSI control characters. Equivalent to `--ansi=never`.", action="store_true", ) parser.add_argument(