@@ -33,32 +33,32 @@ public enum ColorMode { auto, never, always }
3333 @ Option (
3434 names = "--color" ,
3535 description = { "One of: ${COMPLETION-CANDIDATES}" , SHOW_CUSTOM_DEFAULT + "auto" },
36+ arity = "0..1" ,
3637 fallbackValue = "always" ,
38+ defaultValue = "${ASTRA_DEFAULT_COLOR:-auto}" ,
3739 paramLabel = "WHEN"
3840 )
3941 private void setAnsi (ColorMode mode ) {
4042 switch (mode ) {
4143 case always -> this .ansi = Optional .of (Ansi .ON ); // auto is handled by Optional.empty() here, not Ansi.AUTO
4244 case never -> this .ansi = Optional .of (Ansi .OFF );
45+ default -> this .ansi = Optional .empty ();
4346 }
4447 }
4548
4649 @ Option (
4750 names = "--no-color" ,
51+ defaultValue = "${ASTRA_NO_COLOR:-false}" , // no DEFAULT in env var on purpose to better adhere to per-program NO_COLOR semantics
4852 hidden = true
4953 )
5054 private void setAnsi (boolean noColor ) {
51- if (noColor ) {
52- this .ansi = Optional .of (Ansi .OFF );
53- } else {
54- throw new OptionValidationException ("--no-color" , "--no-color must be called without a value (or with 'true'); use --color=never instead" );
55- }
55+ this .ansi = Optional .of ((noColor ) ? Ansi .OFF : Ansi .ON );
5656 }
5757
5858 @ Option (
5959 names = { "--output" , "-o" },
6060 completionCandidates = OutputTypeCompletion .class ,
61- defaultValue = "human" ,
61+ defaultValue = "${ASTRA_DEFAULT_OUTPUT_TYPE:- human} " ,
6262 description = "One of: ${COMPLETION-CANDIDATES}" ,
6363 paramLabel = "FORMAT"
6464 )
@@ -69,6 +69,7 @@ private void setAnsi(boolean noColor) {
6969 @ Option (
7070 names = { "-V" , "--verbose" },
7171 description = "Enable verbose logging output" ,
72+ defaultValue = "${ASTRA_DEFAULT_VERBOSE:-false}" ,
7273 showDefaultValue = Visibility .NEVER
7374 )
7475 private boolean verbose ;
@@ -77,14 +78,16 @@ private void setAnsi(boolean noColor) {
7778 @ Option (
7879 names = { "-q" , "--quiet" },
7980 description = "Only output essential information" ,
81+ defaultValue = "${ASTRA_DEFAULT_QUIET:-false}" ,
8082 showDefaultValue = Visibility .NEVER
8183 )
8284 private boolean quiet ;
8385
8486 @ Getter
8587 @ Option (
8688 names = { "--spinner" },
87- description = { "Enable/disable loading spinners" , SHOW_CUSTOM_DEFAULT + "enabled if tty" },
89+ description = { "Enable/disable loading spinners" , SHOW_CUSTOM_DEFAULT + "enabled if tty and not quiet" },
90+ defaultValue = "${ASTRA_DEFAULT_SPINNER:-" + Option .NULL_VALUE + "}" ,
8891 negatable = true ,
8992 fallbackValue = "true"
9093 )
@@ -100,6 +103,7 @@ private void setAnsi(boolean noColor) {
100103 names = "--dump-logs" ,
101104 description = { "Write all logs to an optionally specified file" , SHOW_CUSTOM_DEFAULT + "${cli.home-folder.path}/logs/<file>.log" },
102105 fallbackValue = "__fallback__" ,
106+ defaultValue = "${ASTRA_DEFAULT_DUMP_LOGS:-" + Option .NULL_VALUE + "}" ,
103107 paramLabel = "FILE" ,
104108 arity = "0..1"
105109 )
@@ -134,6 +138,7 @@ private void setDumpLogs(boolean noDumpLogs) {
134138 @ Option (
135139 names = "--no-input" ,
136140 description = "Don't ask for user input (e.g. confirmation prompts)" ,
141+ defaultValue = "${ASTRA_DEFAULT_NO_INPUT:-false}" ,
137142 showDefaultValue = Visibility .NEVER
138143 )
139144 private boolean noInput ;
0 commit comments