mirror of
https://github.com/floci-io/floci-cli.git
synced 2026-11-22 21:50:47 -05:00
feat(cli): structured output for start, stop and restart, and a status exit code scripts can use (#60)
* feat(cli): structured output for start, stop and restart, and a status exit code scripts can use start, stop and restart print one document with -o json or -o yaml and keep progress off stdout. status exits 1 when the instance is not up (it always exited 0). logs stays plain text and says so when -o is passed. Signed-off-by: Hector Ventura <hectorvent@gmail.com> * feat(cli): report the container's real state after start and stop start reads the state back, so a container that exited during the readiness wait is not reported as running, and stop reports a container docker removed on its own (--rm) as removed. The tests now reject anything after the one document on stdout. Signed-off-by: Hector Ventura <hectorvent@gmail.com> --------- Signed-off-by: Hector Ventura <hectorvent@gmail.com>
This commit is contained in:
1 parent
804e355936
commit
4a9a9b5a4a
10 files changed
+588
-31
No files matched your search
@@ -6,6 +6,7 @@ import io.floci.cli.config.ProfileDefaultValueProvider;
|
||||
import io.floci.cli.config.ProfileNotFoundException;
|
||||
import io.floci.cli.docker.DockerClient;
|
||||
import io.floci.cli.docker.DockerException;
|
||||
import io.floci.cli.output.OutputFormat;
|
||||
import io.floci.cli.output.Printer;
|
||||
import picocli.CommandLine.*;
|
||||
import picocli.CommandLine.Model.CommandSpec;
|
||||
@@ -81,7 +82,9 @@ public class RestartCommand implements Callable<Integer> {
|
||||
|
||||
if (!containerExists()) {
|
||||
// Nothing to stop: start it, rather than failing on the stop.
|
||||
printer.println("Container '" + global.container + "' not found; starting it.");
|
||||
if (printer.format() == OutputFormat.text) {
|
||||
printer.println("Container '" + global.container + "' not found; starting it.");
|
||||
}
|
||||
return start.call();
|
||||
}
|
||||
|
||||
@@ -97,8 +100,10 @@ public class RestartCommand implements Callable<Integer> {
|
||||
* that follows needs neither a pause nor a second inspect-and-remove of its own.
|
||||
*/
|
||||
public StopCommand buildStopCommand() {
|
||||
StopCommand stop = new StopCommand(profile);
|
||||
StopCommand stop = new StopCommand(profile, docker);
|
||||
stop.global = global;
|
||||
// The start that follows reports the restart; one structured document, not two.
|
||||
stop.embedded = true;
|
||||
stop.remove = true;
|
||||
stop.timeout = 10;
|
||||
return stop;
|
||||
|
||||
Reference in new issue
Block a user