mirror of
https://github.com/floci-io/floci-cli.git
synced 2026-12-02 01:43:06 -05:00
refactor!: unify the four product command trees behind ProductProfile (#16)
* refactor!: unify the four product command trees behind ProductProfile
Every shared command now has ONE implementation in commands/,
parameterized by ProductProfile (the single source of per-product
config: endpoint, container, image, env prefix, control prefix,
display name). The gcp/az/oci command classes become ~8-line shims
(GcpStartCommand extends StartCommand { super(ProductProfile.GCP); })
that carry only their per-product help description; the three
near-identical *GlobalOptions clones are deleted. Each product tree
drops from ~1,360 to ~530 lines and copy-drift becomes impossible.
Mechanics: per-product option defaults are constructor-set field
values rendered in help via ${DEFAULT-VALUE} (annotation defaults are
compile-time constants); commands pre-initialize their GlobalOptions
mixin with the profile (picocli uses a non-null mixin field instance
as-is). Verified against a captured baseline of 480 CLI outputs
(every --help x 5 trees, env/status/doctor JSON, exit codes, routing)
plus new pinning tests: ProductProfileTest, ProductTreesParsingTest,
DoctorCheckListTest, GlobalOptionsTest.
Behavior changes, all deliberate:
- snapshot commands in gcp/az/oci trees now perform the real
/snapshots API calls with graceful degradation and exit 1 while the
server lacks the endpoints (previously: note + exit 0)
- product logs/services gained --service/--mode, and services now
resolves the endpoint from the container port mapping in all trees
- the AWS tree brands itself 'Floci AWS' in banners and help,
matching the other products
- snapshot errors link the product issue tracker instead of TODO.md
- completion generates from spec.root() instead of a hardcoded
FlociCli instance (output unchanged)
BREAKING CHANGE: 'floci gcp|az|oci snapshot export/import' (and bare
'floci snapshot ...' with a non-AWS default product) now exit 1
instead of 0 while server-side snapshot support is pending; CI
scripts relying on the silent success of stubbed snapshot commands
will fail.
* fix: snapshot save/load/list/delete resolve the container host port
Same port auto-detection status/services/wait use — a container started
with --port <n> is now reachable by the snapshot commands without an
explicit --endpoint. Applies to all four trees via the unified base
commands.
This commit is contained in:
1 parent
0a65de2303
commit
6dc8fc9df4
100 files changed
+1190
-3283
No files matched your search
@@ -1,116 +1,19 @@
|
||||
package io.floci.cli.commands.az;
|
||||
|
||||
import io.floci.cli.AzGlobalOptions;
|
||||
import io.floci.cli.ProductProfile;
|
||||
import io.floci.cli.commands.DoctorCommand;
|
||||
import io.floci.cli.doctor.Check;
|
||||
import io.floci.cli.doctor.CheckResult;
|
||||
import io.floci.cli.doctor.CheckStatus;
|
||||
import io.floci.cli.docker.DockerClient;
|
||||
import io.floci.cli.doctor.checks.AzCliConnectionStringCheck;
|
||||
import io.floci.cli.doctor.checks.AzCliInstalledCheck;
|
||||
import io.floci.cli.doctor.checks.ContainerRunningCheck;
|
||||
import io.floci.cli.doctor.checks.DockerDaemonCheck;
|
||||
import io.floci.cli.doctor.checks.DockerInstalledCheck;
|
||||
import io.floci.cli.doctor.checks.DockerSocketCheck;
|
||||
import io.floci.cli.doctor.checks.DockerVersionCheck;
|
||||
import io.floci.cli.doctor.checks.EndpointReachableCheck;
|
||||
import io.floci.cli.doctor.checks.ImagePresentCheck;
|
||||
import io.floci.cli.doctor.checks.ImageVersionCheck;
|
||||
import io.floci.cli.doctor.checks.PortAvailableCheck;
|
||||
import io.floci.cli.output.Ansi;
|
||||
import io.floci.cli.output.OutputFormat;
|
||||
import io.floci.cli.output.Printer;
|
||||
import picocli.CommandLine.*;
|
||||
import picocli.CommandLine.Command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
@Command(
|
||||
name = "doctor",
|
||||
description = "Run environment diagnostics for Floci Azure",
|
||||
mixinStandardHelpOptions = true
|
||||
)
|
||||
public class AzDoctorCommand implements Callable<Integer> {
|
||||
public class AzDoctorCommand extends DoctorCommand {
|
||||
|
||||
@Mixin
|
||||
AzGlobalOptions global;
|
||||
|
||||
@Option(names = {"--check"}, description = "Run only a specific check by name", paramLabel = "<name>")
|
||||
String checkName;
|
||||
|
||||
@Option(names = {"--fix"}, description = "Attempt to auto-fix fixable issues")
|
||||
boolean fix;
|
||||
|
||||
public static final List<Check> AZ_COMPANION_CHECKS = List.of(
|
||||
new AzCliInstalledCheck(),
|
||||
new AzCliConnectionStringCheck()
|
||||
);
|
||||
|
||||
private static final List<Check> ALL_CHECKS;
|
||||
|
||||
static {
|
||||
List<Check> checks = new ArrayList<>();
|
||||
checks.add(new DockerInstalledCheck());
|
||||
checks.add(new DockerDaemonCheck());
|
||||
checks.add(new DockerSocketCheck());
|
||||
checks.add(new DockerVersionCheck());
|
||||
checks.add(new PortAvailableCheck());
|
||||
checks.add(new ImagePresentCheck("floci/floci-az"));
|
||||
checks.add(new ImageVersionCheck("floci/floci-az"));
|
||||
checks.add(new ContainerRunningCheck());
|
||||
checks.add(new EndpointReachableCheck());
|
||||
checks.addAll(AZ_COMPANION_CHECKS);
|
||||
ALL_CHECKS = List.copyOf(checks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer call() {
|
||||
Printer printer = global.printer();
|
||||
List<CheckResult> results = new ArrayList<>();
|
||||
String effectiveEndpoint = global.resolvedEndpoint(new DockerClient());
|
||||
|
||||
boolean textMode = printer.format() == OutputFormat.text;
|
||||
|
||||
if (textMode) {
|
||||
printer.println(Ansi.bold("Floci Azure Doctor") + " — checking your environment");
|
||||
printer.println("");
|
||||
}
|
||||
|
||||
for (Check check : ALL_CHECKS) {
|
||||
CheckResult result = check.run(effectiveEndpoint, global.container);
|
||||
if (checkName != null && !result.name().equals(checkName)) continue;
|
||||
results.add(result);
|
||||
if (textMode) DoctorCommand.printResult(printer, result);
|
||||
}
|
||||
|
||||
if (!textMode) {
|
||||
List<Map<String, Object>> structured = new ArrayList<>();
|
||||
for (CheckResult r : results) {
|
||||
Map<String, Object> m = new LinkedHashMap<>();
|
||||
m.put("name", r.name());
|
||||
m.put("status", r.status().name());
|
||||
m.put("message", r.message());
|
||||
if (r.fix() != null) m.put("fix", r.fix());
|
||||
structured.add(m);
|
||||
}
|
||||
printer.structured(structured);
|
||||
return 0;
|
||||
}
|
||||
|
||||
long fails = results.stream().filter(r -> r.status() == CheckStatus.fail).count();
|
||||
long warns = results.stream().filter(r -> r.status() == CheckStatus.warn).count();
|
||||
|
||||
printer.println("");
|
||||
if (fails == 0 && warns == 0) {
|
||||
printer.println(Ansi.green("All checks passed."));
|
||||
} else {
|
||||
printer.println(fails + " issue(s) found (" + fails + " fail, " + warns + " warn)."
|
||||
+ (fix ? "" : " Run with --fix to auto-resolve fixable issues."));
|
||||
}
|
||||
|
||||
return fails > 0 ? 1 : 0;
|
||||
public AzDoctorCommand() {
|
||||
super(ProductProfile.AZ, AZ_COMPANION_CHECKS);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.floci.cli.commands.az;
|
||||
|
||||
import io.floci.cli.AzGlobalOptions;
|
||||
import io.floci.cli.GlobalOptions;
|
||||
import io.floci.cli.ProductProfile;
|
||||
import io.floci.cli.docker.DockerClient;
|
||||
import io.floci.cli.doctor.checks.AzCliConnectionStringCheck;
|
||||
import io.floci.cli.output.Ansi;
|
||||
@@ -31,7 +32,7 @@ public class AzEnvCommand implements Callable<Integer> {
|
||||
Set.of("blob", "queue", "table", "functions", "app-config", "key-vault");
|
||||
|
||||
@Mixin
|
||||
AzGlobalOptions global;
|
||||
GlobalOptions global = new GlobalOptions(ProductProfile.AZ);
|
||||
|
||||
@Option(names = {"--format"},
|
||||
description = "Output mode: connection-string, sdk-vars (default: connection-string)",
|
||||
|
||||
@@ -1,54 +1,17 @@
|
||||
package io.floci.cli.commands.az;
|
||||
|
||||
import io.floci.cli.AzGlobalOptions;
|
||||
import io.floci.cli.docker.DockerClient;
|
||||
import io.floci.cli.docker.DockerException;
|
||||
import io.floci.cli.output.Printer;
|
||||
import picocli.CommandLine.*;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import io.floci.cli.ProductProfile;
|
||||
import io.floci.cli.commands.LogsCommand;
|
||||
import picocli.CommandLine.Command;
|
||||
|
||||
@Command(
|
||||
name = "logs",
|
||||
description = "Fetch logs from the Floci Azure container",
|
||||
mixinStandardHelpOptions = true
|
||||
)
|
||||
public class AzLogsCommand implements Callable<Integer> {
|
||||
public class AzLogsCommand extends LogsCommand {
|
||||
|
||||
@Mixin
|
||||
AzGlobalOptions global;
|
||||
|
||||
@Option(names = {"--follow", "-f"}, description = "Follow log output")
|
||||
boolean follow;
|
||||
|
||||
@Option(names = {"--tail"}, description = "Number of lines from the end (0 = all)", defaultValue = "100", paramLabel = "<n>")
|
||||
int tail;
|
||||
|
||||
@Option(names = {"--since"}, description = "Show logs since duration (e.g. 5m, 1h) or timestamp", paramLabel = "<duration>")
|
||||
String since;
|
||||
|
||||
@Override
|
||||
public Integer call() {
|
||||
Printer printer = global.printer();
|
||||
DockerClient docker = new DockerClient();
|
||||
|
||||
try {
|
||||
var info = docker.inspectContainer(global.container);
|
||||
if (info.isEmpty()) {
|
||||
printer.error("Container '" + global.container + "' not found.\nRun 'floci az start' to launch one.");
|
||||
return 1;
|
||||
}
|
||||
} catch (DockerException e) {
|
||||
printer.error("Failed to inspect container: " + e.getMessage());
|
||||
return 1;
|
||||
}
|
||||
|
||||
try {
|
||||
docker.streamLogs(global.container, follow, tail, since);
|
||||
return 0;
|
||||
} catch (DockerException e) {
|
||||
printer.error("Failed to fetch logs: " + e.getMessage());
|
||||
return 1;
|
||||
}
|
||||
public AzLogsCommand() {
|
||||
super(ProductProfile.AZ);
|
||||
}
|
||||
}
|
||||
@@ -1,40 +1,17 @@
|
||||
package io.floci.cli.commands.az;
|
||||
|
||||
import io.floci.cli.AzGlobalOptions;
|
||||
import io.floci.cli.output.Printer;
|
||||
import picocli.CommandLine.*;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import io.floci.cli.ProductProfile;
|
||||
import io.floci.cli.commands.RestartCommand;
|
||||
import picocli.CommandLine.Command;
|
||||
|
||||
@Command(
|
||||
name = "restart",
|
||||
description = "Stop and restart the Floci Azure container",
|
||||
mixinStandardHelpOptions = true
|
||||
)
|
||||
public class AzRestartCommand implements Callable<Integer> {
|
||||
public class AzRestartCommand extends RestartCommand {
|
||||
|
||||
@Mixin
|
||||
AzGlobalOptions global;
|
||||
|
||||
@Override
|
||||
public Integer call() {
|
||||
Printer printer = global.printer();
|
||||
|
||||
AzStopCommand stop = new AzStopCommand();
|
||||
stop.global = global;
|
||||
stop.remove = false;
|
||||
stop.timeout = 10;
|
||||
int stopResult = stop.call();
|
||||
if (stopResult != 0) return stopResult;
|
||||
|
||||
try { Thread.sleep(1000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); }
|
||||
|
||||
AzStartCommand start = new AzStartCommand();
|
||||
start.global = global;
|
||||
start.port = 4577;
|
||||
start.pull = "missing";
|
||||
start.image = "floci/floci-az:latest";
|
||||
start.detach = false;
|
||||
return start.call();
|
||||
public AzRestartCommand() {
|
||||
super(ProductProfile.AZ);
|
||||
}
|
||||
}
|
||||
@@ -1,55 +1,17 @@
|
||||
package io.floci.cli.commands.az;
|
||||
|
||||
import io.floci.cli.AzGlobalOptions;
|
||||
import io.floci.cli.http.FlociHttpClient;
|
||||
import io.floci.cli.output.Ansi;
|
||||
import io.floci.cli.output.OutputFormat;
|
||||
import io.floci.cli.output.Printer;
|
||||
import picocli.CommandLine.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import io.floci.cli.ProductProfile;
|
||||
import io.floci.cli.commands.ServicesCommand;
|
||||
import picocli.CommandLine.Command;
|
||||
|
||||
@Command(
|
||||
name = "services",
|
||||
description = "List services available in the running Floci Azure instance",
|
||||
mixinStandardHelpOptions = true
|
||||
)
|
||||
public class AzServicesCommand implements Callable<Integer> {
|
||||
public class AzServicesCommand extends ServicesCommand {
|
||||
|
||||
@Mixin
|
||||
AzGlobalOptions global;
|
||||
|
||||
@Override
|
||||
public Integer call() {
|
||||
Printer printer = global.printer();
|
||||
FlociHttpClient client = new FlociHttpClient(global.endpoint);
|
||||
|
||||
List<String> services;
|
||||
try {
|
||||
var health = client.health();
|
||||
services = Arrays.asList(health.services());
|
||||
} catch (Exception e) {
|
||||
printer.error("Could not reach Floci Azure at " + global.endpoint + ".\nIs Floci Azure running? Try 'floci az start'.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (printer.format() != OutputFormat.text) {
|
||||
printer.structured(Map.of("services", services, "count", services.size()));
|
||||
return 0;
|
||||
}
|
||||
|
||||
printer.println(Ansi.bold("Floci Azure Services") + " " + Ansi.gray("(" + services.size() + " enabled)"));
|
||||
printer.println("");
|
||||
for (String svc : services) {
|
||||
printer.println(" " + Ansi.green("✓") + " " + svc);
|
||||
}
|
||||
if (services.isEmpty()) {
|
||||
printer.println(" " + Ansi.gray("(no services reported)"));
|
||||
}
|
||||
|
||||
return 0;
|
||||
public AzServicesCommand() {
|
||||
super(ProductProfile.AZ);
|
||||
}
|
||||
}
|
||||
@@ -1,113 +1,17 @@
|
||||
package io.floci.cli.commands.az;
|
||||
|
||||
import io.floci.cli.AzGlobalOptions;
|
||||
import io.floci.cli.docker.DockerClient;
|
||||
import io.floci.cli.docker.DockerException;
|
||||
import io.floci.cli.output.Ansi;
|
||||
import io.floci.cli.output.Printer;
|
||||
import picocli.CommandLine.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import io.floci.cli.ProductProfile;
|
||||
import io.floci.cli.commands.StartCommand;
|
||||
import picocli.CommandLine.Command;
|
||||
|
||||
@Command(
|
||||
name = "start",
|
||||
description = "Start the Floci Azure emulator container",
|
||||
mixinStandardHelpOptions = true
|
||||
)
|
||||
public class AzStartCommand implements Callable<Integer> {
|
||||
public class AzStartCommand extends StartCommand {
|
||||
|
||||
@Mixin
|
||||
AzGlobalOptions global;
|
||||
|
||||
@Option(names = {"--port"}, description = "Host port to bind (default: 4577)", defaultValue = "4577", paramLabel = "<port>")
|
||||
int port;
|
||||
|
||||
@Option(names = {"--persist"}, description = "Host directory for persistent state", paramLabel = "<dir>")
|
||||
String persistDir;
|
||||
|
||||
@Option(names = {"--services"}, description = "Comma-separated list of services to enable", paramLabel = "<csv>")
|
||||
String services;
|
||||
|
||||
@Option(names = {"--detach"}, description = "Return immediately without waiting for readiness")
|
||||
boolean detach;
|
||||
|
||||
@Option(names = {"--image"}, description = "Image reference to use (default: floci/floci-az:latest)", defaultValue = "floci/floci-az:latest", paramLabel = "<ref>")
|
||||
String image;
|
||||
|
||||
@Option(names = {"--pull"}, description = "Image pull policy: always, missing, never", defaultValue = "missing", paramLabel = "always|missing|never")
|
||||
String pull;
|
||||
|
||||
@Override
|
||||
public Integer call() {
|
||||
Printer printer = global.printer();
|
||||
DockerClient docker = new DockerClient();
|
||||
|
||||
if (!DockerClient.isInstalled()) {
|
||||
printer.error("docker binary not found in PATH.\nInstall Docker Desktop from https://docs.docker.com/get-docker/");
|
||||
return 1;
|
||||
}
|
||||
|
||||
try {
|
||||
var existing = docker.inspectContainer(global.container);
|
||||
if (existing.isPresent()) {
|
||||
String state = existing.get().state();
|
||||
if ("running".equals(state)) {
|
||||
printer.error("Container '" + global.container + "' is already running.\nRun 'floci az stop' first or pass --container <name> to use a different name.");
|
||||
return 1;
|
||||
}
|
||||
printer.println(Ansi.gray("Removing stopped container '" + global.container + "'..."));
|
||||
docker.removeContainer(global.container);
|
||||
}
|
||||
} catch (DockerException e) {
|
||||
printer.error("Failed to inspect container: " + e.getMessage());
|
||||
return 1;
|
||||
}
|
||||
|
||||
try {
|
||||
printer.println(Ansi.gray("Checking image " + image + " (policy: " + pull + ")..."));
|
||||
docker.pull(image, pull);
|
||||
} catch (DockerException e) {
|
||||
printer.error("Failed to pull image: " + e.getMessage() + "\nRun 'floci az start --pull never' to skip pulling.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
List<String> args = new ArrayList<>();
|
||||
args.addAll(List.of("-d", "--name", global.container));
|
||||
args.addAll(List.of("-p", port + ":4577"));
|
||||
args.addAll(DockerClient.dockerSocketRunArgs());
|
||||
if (persistDir != null) {
|
||||
args.addAll(List.of("-v", persistDir + ":/app/data"));
|
||||
// The server defaults to in-memory storage; enable persistent mode so
|
||||
// state is actually written to the mounted directory and survives restarts.
|
||||
args.addAll(List.of("-e", "FLOCI_AZ_STORAGE_MODE=persistent"));
|
||||
}
|
||||
if (services != null && !services.isBlank()) {
|
||||
args.addAll(List.of("-e", "FLOCI_AZ_SERVICES=" + services));
|
||||
}
|
||||
args.add(image);
|
||||
|
||||
try {
|
||||
printer.println("Starting " + Ansi.gold("Floci Azure") + " container...");
|
||||
String id = docker.startContainer(args);
|
||||
printer.println(Ansi.green("Container started") + " (" + id.substring(0, Math.min(12, id.length())) + ")");
|
||||
} catch (DockerException e) {
|
||||
printer.error("Failed to start container: " + e.getMessage());
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (detach) {
|
||||
printer.println(Ansi.gray("Detached. Run 'floci az wait' to poll for readiness."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
global.endpoint = "http://localhost:" + port;
|
||||
|
||||
printer.println(Ansi.gray("Waiting for Floci Azure to be ready..."));
|
||||
AzWaitCommand wait = new AzWaitCommand();
|
||||
wait.global = global;
|
||||
wait.timeout = "30s";
|
||||
return wait.call();
|
||||
public AzStartCommand() {
|
||||
super(ProductProfile.AZ);
|
||||
}
|
||||
}
|
||||
@@ -1,98 +1,17 @@
|
||||
package io.floci.cli.commands.az;
|
||||
|
||||
import io.floci.cli.AzGlobalOptions;
|
||||
import io.floci.cli.docker.DockerClient;
|
||||
import io.floci.cli.docker.DockerException;
|
||||
import io.floci.cli.http.FlociHttpClient;
|
||||
import io.floci.cli.output.Ansi;
|
||||
import io.floci.cli.output.OutputFormat;
|
||||
import io.floci.cli.output.Printer;
|
||||
import picocli.CommandLine.*;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.Callable;
|
||||
import io.floci.cli.ProductProfile;
|
||||
import io.floci.cli.commands.StatusCommand;
|
||||
import picocli.CommandLine.Command;
|
||||
|
||||
@Command(
|
||||
name = "status",
|
||||
description = "Show Floci Azure container and server status",
|
||||
mixinStandardHelpOptions = true
|
||||
)
|
||||
public class AzStatusCommand implements Callable<Integer> {
|
||||
public class AzStatusCommand extends StatusCommand {
|
||||
|
||||
@Mixin
|
||||
AzGlobalOptions global;
|
||||
|
||||
@Override
|
||||
public Integer call() {
|
||||
Printer printer = global.printer();
|
||||
DockerClient docker = new DockerClient();
|
||||
|
||||
String containerState = "not found";
|
||||
String containerImage = "";
|
||||
String containerPorts = "";
|
||||
String effectiveEndpoint = global.endpoint;
|
||||
try {
|
||||
Optional<DockerClient.ContainerInfo> info = docker.inspectContainer(global.container);
|
||||
if (info.isPresent()) {
|
||||
containerState = info.get().state();
|
||||
containerImage = info.get().image();
|
||||
containerPorts = info.get().ports();
|
||||
effectiveEndpoint = global.endpointFromPorts(containerPorts, global.endpoint);
|
||||
}
|
||||
} catch (DockerException e) {
|
||||
containerState = "error: " + e.getMessage();
|
||||
}
|
||||
|
||||
String serverVersion = "unavailable";
|
||||
String serverEdition = "";
|
||||
boolean reachable = false;
|
||||
FlociHttpClient client = new FlociHttpClient(effectiveEndpoint);
|
||||
try {
|
||||
var health = client.health();
|
||||
serverVersion = health.version();
|
||||
serverEdition = health.edition();
|
||||
reachable = true;
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
Map<String, Object> data = new LinkedHashMap<>();
|
||||
data.put("container", global.container);
|
||||
data.put("state", containerState);
|
||||
data.put("image", containerImage);
|
||||
data.put("ports", containerPorts);
|
||||
data.put("endpoint", effectiveEndpoint);
|
||||
data.put("reachable", reachable);
|
||||
data.put("version", serverVersion);
|
||||
data.put("edition", serverEdition);
|
||||
|
||||
if (printer.format() != OutputFormat.text) {
|
||||
printer.structured(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
printer.println(Ansi.bold("Floci Azure Status"));
|
||||
printer.println("");
|
||||
String stateColor = switch (containerState) {
|
||||
case "running" -> Ansi.green(containerState);
|
||||
case "not found" -> Ansi.gray(containerState);
|
||||
default -> Ansi.red(containerState);
|
||||
};
|
||||
printer.println(" Container: " + global.container + " " + stateColor);
|
||||
if (!containerImage.isBlank()) printer.println(" Image: " + containerImage);
|
||||
if (!containerPorts.isBlank()) printer.println(" Ports: " + containerPorts);
|
||||
printer.println(" Endpoint: " + effectiveEndpoint);
|
||||
printer.println(" Reachable: " + (reachable ? Ansi.green("yes") : Ansi.red("no")));
|
||||
if (reachable) {
|
||||
printer.println(" Version: " + serverVersion);
|
||||
if (!serverEdition.isBlank()) printer.println(" Edition: " + serverEdition);
|
||||
}
|
||||
|
||||
if (!reachable && !"running".equals(containerState)) {
|
||||
printer.println("");
|
||||
printer.println(Ansi.gray("Run 'floci az start' to launch Floci Azure."));
|
||||
}
|
||||
|
||||
return 0;
|
||||
public AzStatusCommand() {
|
||||
super(ProductProfile.AZ);
|
||||
}
|
||||
}
|
||||
@@ -1,73 +1,17 @@
|
||||
package io.floci.cli.commands.az;
|
||||
|
||||
import io.floci.cli.AzGlobalOptions;
|
||||
import io.floci.cli.docker.DockerClient;
|
||||
import io.floci.cli.docker.DockerException;
|
||||
import io.floci.cli.output.Ansi;
|
||||
import io.floci.cli.output.Printer;
|
||||
import picocli.CommandLine.*;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import io.floci.cli.ProductProfile;
|
||||
import io.floci.cli.commands.StopCommand;
|
||||
import picocli.CommandLine.Command;
|
||||
|
||||
@Command(
|
||||
name = "stop",
|
||||
description = "Stop the Floci Azure container",
|
||||
mixinStandardHelpOptions = true
|
||||
)
|
||||
public class AzStopCommand implements Callable<Integer> {
|
||||
public class AzStopCommand extends StopCommand {
|
||||
|
||||
@Mixin
|
||||
AzGlobalOptions global;
|
||||
|
||||
@Option(names = {"--remove", "-r"}, description = "Remove the container after stopping")
|
||||
boolean remove;
|
||||
|
||||
@Option(names = {"--timeout"}, description = "Seconds to wait before forcefully killing (default: 10)", defaultValue = "10", paramLabel = "<seconds>")
|
||||
int timeout;
|
||||
|
||||
@Override
|
||||
public Integer call() {
|
||||
Printer printer = global.printer();
|
||||
DockerClient docker = new DockerClient();
|
||||
|
||||
try {
|
||||
var info = docker.inspectContainer(global.container);
|
||||
if (info.isEmpty()) {
|
||||
printer.error("Container '" + global.container + "' not found.\nRun 'floci az start' to launch one.");
|
||||
return 1;
|
||||
}
|
||||
if (!"running".equals(info.get().state())) {
|
||||
printer.println(Ansi.yellow("Container '" + global.container + "' is not running (state: " + info.get().state() + ")"));
|
||||
if (remove) {
|
||||
docker.removeContainer(global.container);
|
||||
printer.println("Container removed.");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
} catch (DockerException e) {
|
||||
printer.error("Failed to inspect container: " + e.getMessage());
|
||||
return 1;
|
||||
}
|
||||
|
||||
try {
|
||||
printer.println("Stopping " + Ansi.gold("Floci Azure") + " container '" + global.container + "'...");
|
||||
docker.stopContainer(global.container, timeout);
|
||||
printer.println(Ansi.green("Stopped."));
|
||||
} catch (DockerException e) {
|
||||
printer.error("Failed to stop container: " + e.getMessage());
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (remove) {
|
||||
try {
|
||||
docker.removeContainer(global.container);
|
||||
printer.println("Container removed.");
|
||||
} catch (DockerException e) {
|
||||
printer.error("Failed to remove container: " + e.getMessage());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
public AzStopCommand() {
|
||||
super(ProductProfile.AZ);
|
||||
}
|
||||
}
|
||||
@@ -1,72 +1,17 @@
|
||||
package io.floci.cli.commands.az;
|
||||
|
||||
import io.floci.cli.AzGlobalOptions;
|
||||
import io.floci.cli.ProductProfile;
|
||||
import io.floci.cli.commands.VersionCommand;
|
||||
import io.floci.cli.docker.DockerClient;
|
||||
import io.floci.cli.http.FlociHttpClient;
|
||||
import io.floci.cli.output.Ansi;
|
||||
import io.floci.cli.output.OutputFormat;
|
||||
import io.floci.cli.output.Printer;
|
||||
import picocli.CommandLine.*;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.Callable;
|
||||
import picocli.CommandLine.Command;
|
||||
|
||||
@Command(
|
||||
name = "version",
|
||||
description = "Show CLI version, connected Floci Azure server version, and image digest",
|
||||
mixinStandardHelpOptions = true
|
||||
)
|
||||
public class AzVersionCommand implements Callable<Integer> {
|
||||
public class AzVersionCommand extends VersionCommand {
|
||||
|
||||
@Mixin
|
||||
AzGlobalOptions global;
|
||||
|
||||
@Override
|
||||
public Integer call() {
|
||||
Printer printer = global.printer();
|
||||
|
||||
String serverVersion = null;
|
||||
String serverEdition = null;
|
||||
String imageDigest = null;
|
||||
|
||||
DockerClient docker = new DockerClient();
|
||||
String effectiveEndpoint = global.resolvedEndpoint(docker);
|
||||
|
||||
FlociHttpClient client = new FlociHttpClient(effectiveEndpoint);
|
||||
try {
|
||||
var info = client.info();
|
||||
serverVersion = info.version();
|
||||
serverEdition = info.edition();
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
try {
|
||||
imageDigest = docker.imageDigest("floci/floci-az").orElse(null);
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
Map<String, Object> data = new LinkedHashMap<>();
|
||||
data.put("cli", VersionCommand.CLI_VERSION);
|
||||
data.put("server", Optional.ofNullable(serverVersion).orElse("unavailable"));
|
||||
data.put("edition", Optional.ofNullable(serverEdition).orElse(""));
|
||||
if (imageDigest != null) data.put("digest", imageDigest);
|
||||
|
||||
if (printer.format() != OutputFormat.text) {
|
||||
printer.structured(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
printer.println(Ansi.bold("Floci CLI") + " " + Ansi.gold(VersionCommand.CLI_VERSION));
|
||||
if (serverVersion != null) {
|
||||
printer.println("Server: " + serverVersion + (serverEdition != null ? " (" + serverEdition + ")" : ""));
|
||||
} else {
|
||||
printer.println("Server: " + Ansi.gray("not reachable at " + effectiveEndpoint));
|
||||
}
|
||||
if (imageDigest != null) {
|
||||
printer.println("Image: " + imageDigest);
|
||||
}
|
||||
|
||||
return 0;
|
||||
public AzVersionCommand() {
|
||||
super(ProductProfile.AZ);
|
||||
}
|
||||
}
|
||||
@@ -1,73 +1,17 @@
|
||||
package io.floci.cli.commands.az;
|
||||
|
||||
import io.floci.cli.AzGlobalOptions;
|
||||
import io.floci.cli.ProductProfile;
|
||||
import io.floci.cli.commands.WaitCommand;
|
||||
import io.floci.cli.http.FlociHttpClient;
|
||||
import io.floci.cli.output.Ansi;
|
||||
import io.floci.cli.output.OutputFormat;
|
||||
import io.floci.cli.output.Printer;
|
||||
import picocli.CommandLine.*;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import picocli.CommandLine.Command;
|
||||
|
||||
@Command(
|
||||
name = "wait",
|
||||
description = "Wait until Floci Azure is ready to accept requests",
|
||||
mixinStandardHelpOptions = true
|
||||
)
|
||||
public class AzWaitCommand implements Callable<Integer> {
|
||||
public class AzWaitCommand extends WaitCommand {
|
||||
|
||||
@Mixin
|
||||
AzGlobalOptions global;
|
||||
|
||||
@Option(names = {"--timeout"}, description = "Maximum time to wait (e.g. 30s, 2m)", defaultValue = "30s", paramLabel = "<duration>")
|
||||
String timeout;
|
||||
|
||||
@Option(names = {"--service"}, description = "Wait until a specific service is enabled", paramLabel = "<name>")
|
||||
String service;
|
||||
|
||||
@Override
|
||||
public Integer call() {
|
||||
Printer printer = global.printer();
|
||||
long timeoutMillis = WaitCommand.parseDuration(timeout);
|
||||
String effectiveEndpoint = global.resolvedEndpoint(new io.floci.cli.docker.DockerClient());
|
||||
FlociHttpClient client = new FlociHttpClient(effectiveEndpoint);
|
||||
Instant deadline = Instant.now().plusMillis(timeoutMillis);
|
||||
|
||||
while (Instant.now().isBefore(deadline)) {
|
||||
if (isReady(client, service)) {
|
||||
if (printer.format() != OutputFormat.text) {
|
||||
printer.structured(Map.of("ready", true, "endpoint", effectiveEndpoint));
|
||||
} else {
|
||||
printer.println(Ansi.green("Floci Azure is ready") + " (" + effectiveEndpoint + ")");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
long remaining = Duration.between(Instant.now(), deadline).toSeconds();
|
||||
printer.print("\r" + Ansi.gray("Waiting... (" + remaining + "s remaining)") + " ");
|
||||
try { Thread.sleep(500); } catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
printer.error("Timed out waiting for Floci Azure after " + timeout + ".\nIs the container running? Try 'floci az status'.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
private boolean isReady(FlociHttpClient client, String requiredService) {
|
||||
try {
|
||||
var health = client.health();
|
||||
if (requiredService == null) return true;
|
||||
for (String s : health.services()) {
|
||||
if (s.equalsIgnoreCase(requiredService)) return true;
|
||||
}
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
public AzWaitCommand() {
|
||||
super(ProductProfile.AZ);
|
||||
}
|
||||
}
|
||||
@@ -1,115 +1,17 @@
|
||||
package io.floci.cli.commands.az.config;
|
||||
|
||||
import io.floci.cli.AzGlobalOptions;
|
||||
import io.floci.cli.config.Profile;
|
||||
import io.floci.cli.config.ProfileStore;
|
||||
import io.floci.cli.output.Ansi;
|
||||
import io.floci.cli.output.Printer;
|
||||
import picocli.CommandLine.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import io.floci.cli.ProductProfile;
|
||||
import io.floci.cli.commands.config.ConfigProfileCommand;
|
||||
import picocli.CommandLine.Command;
|
||||
|
||||
@Command(
|
||||
name = "profile",
|
||||
description = "Manage Floci Azure configuration profiles",
|
||||
mixinStandardHelpOptions = true,
|
||||
subcommands = {HelpCommand.class}
|
||||
mixinStandardHelpOptions = true
|
||||
)
|
||||
public class AzConfigProfileCommand implements Callable<Integer> {
|
||||
public class AzConfigProfileCommand extends ConfigProfileCommand {
|
||||
|
||||
@Mixin
|
||||
AzGlobalOptions global;
|
||||
|
||||
@Parameters(index = "0", description = "Action: list, show, create, delete", paramLabel = "list|show|create|delete")
|
||||
String action;
|
||||
|
||||
@Parameters(index = "1", description = "Profile name (required for show, create, delete)", arity = "0..1", paramLabel = "<name>")
|
||||
String name;
|
||||
|
||||
@Override
|
||||
public Integer call() {
|
||||
Printer printer = global.printer();
|
||||
ProfileStore store = new ProfileStore();
|
||||
|
||||
return switch (action.toLowerCase()) {
|
||||
case "list" -> listProfiles(printer, store);
|
||||
case "show" -> showProfile(printer, store);
|
||||
case "create" -> createProfile(printer, store);
|
||||
case "delete" -> deleteProfile(printer, store);
|
||||
default -> {
|
||||
printer.error("Unknown action '" + action + "'. Use: list, show, create, delete");
|
||||
yield 1;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private int listProfiles(Printer printer, ProfileStore store) {
|
||||
try {
|
||||
List<Profile> profiles = store.list();
|
||||
if (profiles.isEmpty()) {
|
||||
printer.println(Ansi.gray("No profiles found. Create one with: floci az config profile create <name>"));
|
||||
return 0;
|
||||
}
|
||||
printer.println(Ansi.bold("Profiles:"));
|
||||
for (Profile p : profiles) {
|
||||
printer.println(" " + p.name + Ansi.gray(" " + (p.endpoint != null ? p.endpoint : "")));
|
||||
}
|
||||
return 0;
|
||||
} catch (IOException e) {
|
||||
printer.error("Could not list profiles: " + e.getMessage());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
private int showProfile(Printer printer, ProfileStore store) {
|
||||
if (name == null) { printer.error("Profile name required."); return 1; }
|
||||
try {
|
||||
var profile = store.get(name);
|
||||
if (profile.isEmpty()) { printer.error("Profile '" + name + "' not found."); return 1; }
|
||||
Profile p = profile.get();
|
||||
printer.println(Ansi.bold("Profile: ") + p.name);
|
||||
if (p.endpoint != null) printer.println(" endpoint: " + p.endpoint);
|
||||
if (p.container != null) printer.println(" container: " + p.container);
|
||||
if (p.image != null) printer.println(" image: " + p.image);
|
||||
if (p.port != null) printer.println(" port: " + p.port);
|
||||
if (p.persistDir != null) printer.println(" persistDir: " + p.persistDir);
|
||||
if (p.services != null) printer.println(" services: " + p.services);
|
||||
return 0;
|
||||
} catch (IOException e) {
|
||||
printer.error("Could not read profile: " + e.getMessage());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
private int createProfile(Printer printer, ProfileStore store) {
|
||||
if (name == null) { printer.error("Profile name required."); return 1; }
|
||||
try {
|
||||
if (store.get(name).isPresent()) {
|
||||
printer.error("Profile '" + name + "' already exists. Delete it first or edit " + store.profileFile(name));
|
||||
return 1;
|
||||
}
|
||||
Profile p = new Profile(name);
|
||||
store.save(p);
|
||||
printer.println(Ansi.green("Created") + " profile '" + name + "' at " + store.profileFile(name));
|
||||
printer.println(Ansi.gray("Edit the file to customize endpoint, container, image, etc."));
|
||||
return 0;
|
||||
} catch (IOException e) {
|
||||
printer.error("Could not create profile: " + e.getMessage());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
private int deleteProfile(Printer printer, ProfileStore store) {
|
||||
if (name == null) { printer.error("Profile name required."); return 1; }
|
||||
try {
|
||||
if (!store.delete(name)) { printer.error("Profile '" + name + "' not found."); return 1; }
|
||||
printer.println(Ansi.green("Deleted") + " profile '" + name + "'");
|
||||
return 0;
|
||||
} catch (IOException e) {
|
||||
printer.error("Could not delete profile: " + e.getMessage());
|
||||
return 1;
|
||||
}
|
||||
public AzConfigProfileCommand() {
|
||||
super(ProductProfile.AZ);
|
||||
}
|
||||
}
|
||||
@@ -1,70 +1,17 @@
|
||||
package io.floci.cli.commands.az.config;
|
||||
|
||||
import io.floci.cli.AzGlobalOptions;
|
||||
import io.floci.cli.config.Profile;
|
||||
import io.floci.cli.config.ProfileStore;
|
||||
import io.floci.cli.output.Ansi;
|
||||
import io.floci.cli.output.OutputFormat;
|
||||
import io.floci.cli.output.Printer;
|
||||
import picocli.CommandLine.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.Callable;
|
||||
import io.floci.cli.ProductProfile;
|
||||
import io.floci.cli.commands.config.ConfigShowCommand;
|
||||
import picocli.CommandLine.Command;
|
||||
|
||||
@Command(
|
||||
name = "show",
|
||||
description = "Show the active Floci Azure configuration",
|
||||
mixinStandardHelpOptions = true
|
||||
)
|
||||
public class AzConfigShowCommand implements Callable<Integer> {
|
||||
public class AzConfigShowCommand extends ConfigShowCommand {
|
||||
|
||||
@Mixin
|
||||
AzGlobalOptions global;
|
||||
|
||||
@Override
|
||||
public Integer call() {
|
||||
Printer printer = global.printer();
|
||||
ProfileStore store = new ProfileStore();
|
||||
|
||||
Profile active = new Profile(global.profile != null ? global.profile : "default");
|
||||
active.endpoint = global.endpoint;
|
||||
active.container = global.container;
|
||||
active.output = global.output != null ? global.output.name() : "text";
|
||||
|
||||
if (global.profile != null) {
|
||||
try {
|
||||
Optional<Profile> loaded = store.get(global.profile);
|
||||
if (loaded.isPresent()) {
|
||||
active = loaded.get();
|
||||
} else {
|
||||
printer.warn("Profile '" + global.profile + "' not found. Using defaults.");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
printer.warn("Could not load profile: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> data = new LinkedHashMap<>();
|
||||
data.put("profile", active.name);
|
||||
data.put("endpoint", active.endpoint != null ? active.endpoint : global.endpoint);
|
||||
data.put("container", active.container != null ? active.container : global.container);
|
||||
data.put("output", active.output);
|
||||
|
||||
if (printer.format() != OutputFormat.text) {
|
||||
printer.structured(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
printer.println(Ansi.bold("Active Configuration (Floci Azure)"));
|
||||
printer.println("");
|
||||
printer.println(" Profile: " + active.name);
|
||||
printer.println(" Endpoint: " + (active.endpoint != null ? active.endpoint : global.endpoint));
|
||||
printer.println(" Container: " + (active.container != null ? active.container : global.container));
|
||||
printer.println(" Output: " + (active.output != null ? active.output : "text"));
|
||||
|
||||
return 0;
|
||||
public AzConfigShowCommand() {
|
||||
super(ProductProfile.AZ);
|
||||
}
|
||||
}
|
||||
@@ -1,91 +1,17 @@
|
||||
package io.floci.cli.commands.az.config;
|
||||
|
||||
import io.floci.cli.AzGlobalOptions;
|
||||
import io.floci.cli.output.Ansi;
|
||||
import io.floci.cli.output.Printer;
|
||||
import picocli.CommandLine.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.regex.Pattern;
|
||||
import io.floci.cli.ProductProfile;
|
||||
import io.floci.cli.commands.config.ConfigValidateCommand;
|
||||
import picocli.CommandLine.Command;
|
||||
|
||||
@Command(
|
||||
name = "validate",
|
||||
description = "Validate a docker-compose.yml file for Floci Azure compatibility",
|
||||
mixinStandardHelpOptions = true
|
||||
)
|
||||
public class AzConfigValidateCommand implements Callable<Integer> {
|
||||
public class AzConfigValidateCommand extends ConfigValidateCommand {
|
||||
|
||||
@Mixin
|
||||
AzGlobalOptions global;
|
||||
|
||||
@Option(names = {"--file", "-f"}, description = "Path to docker-compose file", paramLabel = "<path>")
|
||||
String file;
|
||||
|
||||
@Override
|
||||
public Integer call() {
|
||||
Printer printer = global.printer();
|
||||
|
||||
Path composeFile = resolveComposeFile();
|
||||
if (composeFile == null) {
|
||||
printer.error("No docker-compose file found. Pass --file <path> or run in a directory with docker-compose.yml.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
String content;
|
||||
try {
|
||||
content = Files.readString(composeFile);
|
||||
} catch (IOException e) {
|
||||
printer.error("Could not read " + composeFile + ": " + e.getMessage());
|
||||
return 1;
|
||||
}
|
||||
|
||||
printer.println(Ansi.bold("Validating") + " " + composeFile);
|
||||
printer.println("");
|
||||
|
||||
List<String> issues = new ArrayList<>();
|
||||
List<String> warnings = new ArrayList<>();
|
||||
|
||||
if (!content.contains("/var/run/docker.sock")) {
|
||||
warnings.add("Missing /var/run/docker.sock volume mount — required for Azure Functions");
|
||||
}
|
||||
|
||||
if (!Pattern.compile("4577\\s*:\\s*4577").matcher(content).find()) {
|
||||
issues.add("Port mapping 4577:4577 not found — Floci Azure listens on 4577 by default");
|
||||
}
|
||||
|
||||
if (!content.contains("floci/floci-az") && !content.contains("ghcr.io/floci-io/floci-az")) {
|
||||
warnings.add("Floci Azure image reference not detected — ensure your service uses floci/floci-az");
|
||||
}
|
||||
|
||||
for (String issue : issues) {
|
||||
printer.println(" " + Ansi.red("✗") + " " + issue);
|
||||
}
|
||||
for (String warn : warnings) {
|
||||
printer.println(" " + Ansi.yellow("⚠") + " " + warn);
|
||||
}
|
||||
if (issues.isEmpty() && warnings.isEmpty()) {
|
||||
printer.println(" " + Ansi.green("✓") + " Compose file looks good");
|
||||
}
|
||||
|
||||
printer.println("");
|
||||
if (!issues.isEmpty()) {
|
||||
printer.println(issues.size() + " error(s) found.");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private Path resolveComposeFile() {
|
||||
if (file != null) return Path.of(file);
|
||||
for (String name : List.of("docker-compose.yml", "docker-compose.yaml", "compose.yml", "compose.yaml")) {
|
||||
Path p = Path.of(name);
|
||||
if (Files.exists(p)) return p;
|
||||
}
|
||||
return null;
|
||||
public AzConfigValidateCommand() {
|
||||
super(ProductProfile.AZ, false, "Azure Functions");
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import picocli.CommandLine.*;
|
||||
|
||||
@Command(
|
||||
name = "snapshot",
|
||||
description = "Manage Floci Azure state snapshots (coming soon)",
|
||||
description = "Manage Floci Azure state snapshots",
|
||||
mixinStandardHelpOptions = true,
|
||||
subcommands = {
|
||||
AzSnapshotSaveCommand.class,
|
||||
|
||||
@@ -1,28 +1,17 @@
|
||||
package io.floci.cli.commands.az.snapshot;
|
||||
|
||||
import io.floci.cli.AzGlobalOptions;
|
||||
import io.floci.cli.output.Ansi;
|
||||
import picocli.CommandLine.*;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import io.floci.cli.ProductProfile;
|
||||
import io.floci.cli.commands.snapshot.SnapshotDeleteCommand;
|
||||
import picocli.CommandLine.Command;
|
||||
|
||||
@Command(
|
||||
name = "delete",
|
||||
description = "Delete a Floci Azure snapshot",
|
||||
mixinStandardHelpOptions = true
|
||||
)
|
||||
public class AzSnapshotDeleteCommand implements Callable<Integer> {
|
||||
public class AzSnapshotDeleteCommand extends SnapshotDeleteCommand {
|
||||
|
||||
@Mixin
|
||||
AzGlobalOptions global;
|
||||
|
||||
@Parameters(index = "0", description = "Snapshot name", paramLabel = "<name>")
|
||||
String name;
|
||||
|
||||
@Override
|
||||
public Integer call() {
|
||||
global.printer().println(Ansi.yellow("Snapshots are not yet available for Floci Azure.") +
|
||||
"\nTrack progress: https://github.com/floci-io/floci-az/issues");
|
||||
return 0;
|
||||
public AzSnapshotDeleteCommand() {
|
||||
super(ProductProfile.AZ);
|
||||
}
|
||||
}
|
||||
@@ -1,31 +1,17 @@
|
||||
package io.floci.cli.commands.az.snapshot;
|
||||
|
||||
import io.floci.cli.AzGlobalOptions;
|
||||
import io.floci.cli.output.Ansi;
|
||||
import picocli.CommandLine.*;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import io.floci.cli.ProductProfile;
|
||||
import io.floci.cli.commands.snapshot.SnapshotExportCommand;
|
||||
import picocli.CommandLine.Command;
|
||||
|
||||
@Command(
|
||||
name = "export",
|
||||
description = "Export a Floci Azure snapshot to a tarball file",
|
||||
mixinStandardHelpOptions = true
|
||||
)
|
||||
public class AzSnapshotExportCommand implements Callable<Integer> {
|
||||
public class AzSnapshotExportCommand extends SnapshotExportCommand {
|
||||
|
||||
@Mixin
|
||||
AzGlobalOptions global;
|
||||
|
||||
@Parameters(index = "0", description = "Snapshot name", paramLabel = "<name>")
|
||||
String name;
|
||||
|
||||
@Option(names = {"--file", "-f"}, description = "Destination file path", required = true, paramLabel = "<path>")
|
||||
String outputFile;
|
||||
|
||||
@Override
|
||||
public Integer call() {
|
||||
global.printer().println(Ansi.yellow("Snapshots are not yet available for Floci Azure.") +
|
||||
"\nTrack progress: https://github.com/floci-io/floci-az/issues");
|
||||
return 0;
|
||||
public AzSnapshotExportCommand() {
|
||||
super(ProductProfile.AZ);
|
||||
}
|
||||
}
|
||||
@@ -1,31 +1,17 @@
|
||||
package io.floci.cli.commands.az.snapshot;
|
||||
|
||||
import io.floci.cli.AzGlobalOptions;
|
||||
import io.floci.cli.output.Ansi;
|
||||
import picocli.CommandLine.*;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import io.floci.cli.ProductProfile;
|
||||
import io.floci.cli.commands.snapshot.SnapshotImportCommand;
|
||||
import picocli.CommandLine.Command;
|
||||
|
||||
@Command(
|
||||
name = "import",
|
||||
description = "Import a Floci Azure snapshot from a tarball file",
|
||||
mixinStandardHelpOptions = true
|
||||
)
|
||||
public class AzSnapshotImportCommand implements Callable<Integer> {
|
||||
public class AzSnapshotImportCommand extends SnapshotImportCommand {
|
||||
|
||||
@Mixin
|
||||
AzGlobalOptions global;
|
||||
|
||||
@Option(names = {"--file", "-f"}, description = "Source tarball path", required = true, paramLabel = "<path>")
|
||||
String inputFile;
|
||||
|
||||
@Option(names = {"--name"}, description = "Name for the imported snapshot", paramLabel = "<name>")
|
||||
String name;
|
||||
|
||||
@Override
|
||||
public Integer call() {
|
||||
global.printer().println(Ansi.yellow("Snapshots are not yet available for Floci Azure.") +
|
||||
"\nTrack progress: https://github.com/floci-io/floci-az/issues");
|
||||
return 0;
|
||||
public AzSnapshotImportCommand() {
|
||||
super(ProductProfile.AZ);
|
||||
}
|
||||
}
|
||||
@@ -1,34 +1,17 @@
|
||||
package io.floci.cli.commands.az.snapshot;
|
||||
|
||||
import io.floci.cli.AzGlobalOptions;
|
||||
import io.floci.cli.output.Ansi;
|
||||
import io.floci.cli.output.OutputFormat;
|
||||
import io.floci.cli.output.Printer;
|
||||
import picocli.CommandLine.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import io.floci.cli.ProductProfile;
|
||||
import io.floci.cli.commands.snapshot.SnapshotListCommand;
|
||||
import picocli.CommandLine.Command;
|
||||
|
||||
@Command(
|
||||
name = "list",
|
||||
description = "List available Floci Azure snapshots",
|
||||
mixinStandardHelpOptions = true
|
||||
)
|
||||
public class AzSnapshotListCommand implements Callable<Integer> {
|
||||
public class AzSnapshotListCommand extends SnapshotListCommand {
|
||||
|
||||
@Mixin
|
||||
AzGlobalOptions global;
|
||||
|
||||
@Override
|
||||
public Integer call() {
|
||||
Printer printer = global.printer();
|
||||
if (printer.format() != OutputFormat.text) {
|
||||
printer.structured(Map.of("snapshots", List.of(), "note", "not yet available"));
|
||||
return 0;
|
||||
}
|
||||
printer.println(Ansi.gray("No snapshots found.") +
|
||||
" (Snapshot support for Floci Azure is coming — https://github.com/floci-io/floci-az/issues)");
|
||||
return 0;
|
||||
public AzSnapshotListCommand() {
|
||||
super(ProductProfile.AZ);
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,17 @@
|
||||
package io.floci.cli.commands.az.snapshot;
|
||||
|
||||
import io.floci.cli.AzGlobalOptions;
|
||||
import io.floci.cli.output.Ansi;
|
||||
import picocli.CommandLine.*;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import io.floci.cli.ProductProfile;
|
||||
import io.floci.cli.commands.snapshot.SnapshotLoadCommand;
|
||||
import picocli.CommandLine.Command;
|
||||
|
||||
@Command(
|
||||
name = "load",
|
||||
description = "Restore a saved Floci Azure snapshot",
|
||||
description = "Load a Floci Azure snapshot",
|
||||
mixinStandardHelpOptions = true
|
||||
)
|
||||
public class AzSnapshotLoadCommand implements Callable<Integer> {
|
||||
public class AzSnapshotLoadCommand extends SnapshotLoadCommand {
|
||||
|
||||
@Mixin
|
||||
AzGlobalOptions global;
|
||||
|
||||
@Parameters(index = "0", description = "Snapshot name", paramLabel = "<name>")
|
||||
String name;
|
||||
|
||||
@Override
|
||||
public Integer call() {
|
||||
global.printer().println(Ansi.yellow("Snapshots are not yet available for Floci Azure.") +
|
||||
"\nTrack progress: https://github.com/floci-io/floci-az/issues");
|
||||
return 0;
|
||||
public AzSnapshotLoadCommand() {
|
||||
super(ProductProfile.AZ);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +1,17 @@
|
||||
package io.floci.cli.commands.az.snapshot;
|
||||
|
||||
import io.floci.cli.AzGlobalOptions;
|
||||
import io.floci.cli.output.Ansi;
|
||||
import io.floci.cli.output.Printer;
|
||||
import picocli.CommandLine.*;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import io.floci.cli.ProductProfile;
|
||||
import io.floci.cli.commands.snapshot.SnapshotSaveCommand;
|
||||
import picocli.CommandLine.Command;
|
||||
|
||||
@Command(
|
||||
name = "save",
|
||||
description = "Save the current Floci Azure state as a named snapshot",
|
||||
mixinStandardHelpOptions = true
|
||||
)
|
||||
public class AzSnapshotSaveCommand implements Callable<Integer> {
|
||||
public class AzSnapshotSaveCommand extends SnapshotSaveCommand {
|
||||
|
||||
@Mixin
|
||||
AzGlobalOptions global;
|
||||
|
||||
@Parameters(index = "0", description = "Snapshot name", paramLabel = "<name>")
|
||||
String name;
|
||||
|
||||
@Option(names = {"--message", "-m"}, description = "Optional description", paramLabel = "<text>")
|
||||
String message;
|
||||
|
||||
@Override
|
||||
public Integer call() {
|
||||
global.printer().println(Ansi.yellow("Snapshots are not yet available for Floci Azure.") +
|
||||
"\nTrack progress: https://github.com/floci-io/floci-az/issues");
|
||||
return 0;
|
||||
public AzSnapshotSaveCommand() {
|
||||
super(ProductProfile.AZ);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user