mirror of
https://github.com/floci-io/floci-cli.git
synced 2026-11-22 21:50:47 -05:00
fix(cli): keep wait's spinner out of -o json, reject bad durations and make --verbose work (#48)
* fix(cli): keep wait's spinner out of -o json, reject bad durations and make --verbose work wait draws its spinner only for text output on a terminal and clears it before the result; --timeout values that are not a positive number with ms, s, m or h exit 2 with a hint instead of a stack trace; --verbose now echoes each docker command to stderr and prints stack traces for errors. * fix(cli): reject durations that overflow and pin the spinner rule on a terminal A duration is checked for sign before it is converted and the conversion is overflow-checked, so -9223372036854775807s no longer wraps to a positive timeout. wait takes its terminal check through a seam, with tests for json, yaml and text output on a terminal.
This commit is contained in:
1 parent
7ecc895baa
commit
52ebdee98d
8 files changed
+230
-10
No files matched your search
@@ -27,6 +27,9 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class GlobalOptions {
|
||||
|
||||
/** System property that {@code --verbose} sets; read where no GlobalOptions is at hand. */
|
||||
public static final String VERBOSE_PROPERTY = "floci.verbose";
|
||||
|
||||
// The command this mixin belongs to, so hints can tell which flags were actually typed.
|
||||
// Null for commands built by hand (restart's start), which were never parsed.
|
||||
@Spec(Spec.Target.MIXEE)
|
||||
@@ -122,6 +125,10 @@ public class GlobalOptions {
|
||||
if (noColor || !isStdoutTty()) {
|
||||
Ansi.disable();
|
||||
}
|
||||
// Read by the exception handler (stack traces) and DockerClient (the commands it runs).
|
||||
if (verbose) {
|
||||
System.setProperty(VERBOSE_PROPERTY, "true");
|
||||
}
|
||||
return new Printer(System.out, System.err, output, quiet);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user