Skip to content

Commit 475701a

Browse files
simonbairdclaude
andcommitted
Bring color text support to ec validate input text
This is a small enhancement for the change in PR #3041. Co-authored-by: Claude Code <[email protected]> Ref: https://issues.redhat.com/browse/EC-1576
1 parent 048da8f commit 475701a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

cmd/validate/input.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ func validateInputCmd(validate InputValidationFunc) *cobra.Command {
4343
effectiveTime string
4444
filePaths []string
4545
filterType string
46+
forceColor bool
4647
info bool
4748
namespaces []string
49+
noColor bool
4850
output []string
4951
policy policy.Policy
5052
policyConfiguration string
@@ -213,6 +215,8 @@ func validateInputCmd(validate InputValidationFunc) *cobra.Command {
213215
return err
214216
}
215217

218+
utils.SetColorEnabled(data.noColor, data.forceColor)
219+
216220
p := format.NewTargetParser(input.Text, format.Options{ShowSuccesses: showSuccesses, ShowWarnings: showWarnings}, cmd.OutOrStdout(), utils.FS(cmd.Context()))
217221
if err := report.WriteAll(data.output, p); err != nil {
218222
return err
@@ -264,6 +268,12 @@ func validateInputCmd(validate InputValidationFunc) *cobra.Command {
264268
- "include-exclude": Uses traditional include/exclude filtering without pipeline intentions
265269
- "ec-policy": Uses Enterprise Contract policy filtering with pipeline intention support`))
266270

271+
cmd.Flags().BoolVar(&data.noColor, "no-color", false, hd.Doc(`
272+
Disable color when using text output even when the current terminal supports it`))
273+
274+
cmd.Flags().BoolVar(&data.forceColor, "color", false, hd.Doc(`
275+
Enable color when using text output even when the current terminal does not support it`))
276+
267277
if err := cmd.MarkFlagRequired("file"); err != nil {
268278
panic(err)
269279
}

docs/modules/ROOT/pages/ec_validate_input.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ of the git repo. For git repos not hosted on 'github.com' or 'gitlab.com', prefi
3939

4040
== Options
4141

42+
--color:: Enable color when using text output even when the current terminal does not support it (Default: false)
4243
--effective-time:: Run policy checks with the provided time. Useful for testing rules with
4344
effective dates in the future. The value can be "now" (default) - for
4445
current time, or a RFC3339 formatted value, e.g. 2022-11-18T00:00:00Z. (Default: now)
@@ -50,6 +51,7 @@ current time, or a RFC3339 formatted value, e.g. 2022-11-18T00:00:00Z. (Default:
5051
--info:: Include additional information on the failures. For instance for policy
5152
violations, include the title and the description of the failed policy
5253
rule. (Default: false)
54+
--no-color:: Disable color when using text output even when the current terminal supports it (Default: false)
5355
-o, --output:: Write output to a file in a specific format, e.g. yaml=/tmp/output.yaml. Use empty string
5456
path for stdout, e.g. yaml. May be used multiple times. Possible formats are:
5557
json, yaml, text, summary. In following format and file path

0 commit comments

Comments
 (0)