diff --git a/README.md b/README.md index f55dcdc..8ae4af0 100644 --- a/README.md +++ b/README.md @@ -312,15 +312,21 @@ All commands support `--help`. ## Global Flags +Every tree takes the same flags; only the defaults differ. Marks are plain ASCII without +`--no-emoji` too whenever the output is not a terminal (a pipe, a file, CI logs) or `NO_COLOR` is +set. `--json` wins when it is combined with `--output`. + ### AWS global flags ``` --endpoint Floci server URL (default: http://localhost:4566, env: FLOCI_ENDPOINT) --container Container name (default: floci, env: FLOCI_CONTAINER) --output|-o text|json|yaml Output format (default: text) +--json Shorthand for --output json --quiet, -q Suppress non-error output --verbose, -v Debug logging to stderr --no-color Disable ANSI colors +--no-emoji Plain ASCII marks (+ ! x ->) instead of Unicode ones --profile Load settings from ~/.floci/profiles/.yaml ``` @@ -332,9 +338,11 @@ Explicit flags override the profile; the profile overrides the environment varia --endpoint Floci GCP server URL (default: http://localhost:4588, env: FLOCI_GCP_ENDPOINT) --container Container name (default: floci-gcp, env: FLOCI_GCP_CONTAINER) --output|-o text|json|yaml Output format (default: text) +--json Shorthand for --output json --quiet, -q Suppress non-error output --verbose, -v Debug logging to stderr --no-color Disable ANSI colors +--no-emoji Plain ASCII marks (+ ! x ->) instead of Unicode ones --profile Load settings from ~/.floci/profiles/.yaml ``` @@ -346,9 +354,11 @@ Explicit flags override the profile; the profile overrides the environment varia --endpoint Floci Azure server URL (default: http://localhost:4577, env: FLOCI_AZ_ENDPOINT) --container Container name (default: floci-az, env: FLOCI_AZ_CONTAINER) --output|-o text|json|yaml Output format (default: text) +--json Shorthand for --output json --quiet, -q Suppress non-error output --verbose, -v Debug logging to stderr --no-color Disable ANSI colors +--no-emoji Plain ASCII marks (+ ! x ->) instead of Unicode ones --profile Load settings from ~/.floci/profiles/.yaml ``` @@ -360,9 +370,11 @@ Explicit flags override the profile; the profile overrides the environment varia --endpoint Floci OCI server URL (default: http://localhost:4599, env: FLOCI_OCI_ENDPOINT) --container Container name (default: floci-oci, env: FLOCI_OCI_CONTAINER) --output|-o text|json|yaml Output format (default: text) +--json Shorthand for --output json --quiet, -q Suppress non-error output --verbose, -v Debug logging to stderr --no-color Disable ANSI colors +--no-emoji Plain ASCII marks (+ ! x ->) instead of Unicode ones --profile Load settings from ~/.floci/profiles/.yaml ``` @@ -459,16 +471,27 @@ floci stop # graceful stop (10s timeout) floci stop --timeout 30 # wait up to 30s before force-kill floci stop --timeout -1 # never force-kill: wait for the container to exit floci stop --remove # also remove the container after stopping +floci stop -o json # {"container", "state", "stopped", "removed"} ``` +`start`, `stop` and `restart` print one document with `-o json` or `-o yaml` and nothing else on +stdout: the progress lines are left out and docker's pull progress goes to stderr. `start` and +`restart` report `container`, `id`, `image`, `endpoint`, `state` and `ready` (`ready` is absent +with `--detach`). `logs` prints the container's own output and stays plain text. + ### `floci status` / `floci gcp status` / `floci az status` / `floci oci status` ```sh floci status # auto-detects endpoint from container port mapping floci status --container myfloci # target a specific container floci status -o json # structured output +floci status >/dev/null && echo up # exit 0: the instance is up, exit 1: it is not ``` +`status` exits 0 when the server answers and its container, if there is one, is running, and 1 +otherwise, in every output format. An instance with no local container (a remote `--endpoint`, a +Compose service under another name) counts as up when it answers. + ### `floci env` Prints AWS environment variables pointing at the running Floci instance. The default @@ -678,6 +701,10 @@ floci version # CLI version, server version, image digest floci version -o json ``` +`floci version` and `floci status` warn on stderr when the AWS server is older than 1.5.0, the +oldest version this CLI supports. The GCP, Azure and OCI emulators are versioned separately and +have no minimum yet. + ### `floci services` / `floci gcp services` / `floci az services` / `floci oci services` ```sh @@ -710,6 +737,7 @@ floci config profile list # list saved profiles: container, por floci config profile create # create a new profile with the tree's defaults floci config profile create --container --port

--persist

--services --image --namespace floci config profile show # show a profile +floci config profile edit # open the profile in $VISUAL or $EDITOR, then check it still reads floci config profile delete # delete a profile floci config validate -f docker-compose.yml # validate a Compose file ``` @@ -718,6 +746,21 @@ Each product tree has its own `config show|validate|profile` (`floci gcp config uses that product's defaults; `config default-product` is available through bare `floci config` and `floci aws config`, but not through the GCP, Azure, or OCI config trees. +`config validate` reads the Compose file and checks the service that runs the emulator (found by +its image; a file with a single service is checked whatever its image is): + +| Check | Result when it fails | +|---|---| +| The emulator port is mapped over TCP (`"4566:4566"`, `"5566:4566"`, `"127.0.0.1:5566:4566"`, a range, or the long form; any host port works) | error | +| A socket is mounted at `/var/run/docker.sock` in the container (the host side may be any socket) | error where the product needs it, otherwise a warning | +| The volume at `/app/data` is writable and not bound to a file | error | +| A volume at `/app/data` comes with `_STORAGE_MODE=persistent`, and the other way round | warning | +| The image tag is not older than the oldest version this CLI supports (AWS tree) | warning | + +It exits 1 when there is an error and 0 otherwise. `-o json` and `-o yaml` print +`file`, `service`, `valid`, `errors` and `warnings`, also for a file that cannot be parsed. An +`env_file` is not read, so nothing is said about a storage mode it may set. + #### Profiles Profiles are stored in `~/.floci/profiles/.yaml`. Pass `--profile ` to any command to @@ -844,6 +887,8 @@ floci completion bash >> ~/.bashrc floci completion zsh >> ~/.zshrc ``` +Completion scripts are generated for bash and zsh. Any other shell name is a usage error (exit 2). + ### `floci update` Self-update the CLI in place: downloads the release binary from GitHub, verifies its @@ -893,7 +938,7 @@ Where a command's codes carry a specific meaning a script can rely on: | `stop` | stopped, or was not running | no such container, or Docker failed | bad flag or profile | | `reset` | state reset | declined, not available on this server, or no running instance to reset | no terminal to ask on and no `--yes` | | `config validate` | no errors (warnings allowed) | errors found, or the file cannot be read | bad flag | -| `config profile ...` | done | not found, already exists, cannot be read, or `--port` is out of range | the profile name is not valid | +| `config profile ...` | done | not found, already exists, cannot be read, `--port` is out of range, or (for `edit`) no editor is set, the editor failed or the file no longer parses | the profile name is not valid | | `config default-product` | saved | not `aws`, `gcp`, `az` or `oci`, or the file cannot be written | bad flag | | `env` | variables printed | | `--shell` is not supported | | `completion` | script printed | | the shell is not `bash` or `zsh` | diff --git a/docs/help/floci-aws-completion.txt b/docs/help/floci-aws-completion.txt index d05d148..bdd7acc 100644 --- a/docs/help/floci-aws-completion.txt +++ b/docs/help/floci-aws-completion.txt @@ -1,12 +1,14 @@ -Usage: floci aws completion [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] bash|zsh|fish|powershell +Usage: floci aws completion [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] bash|zsh Generate shell completion scripts - bash|zsh|fish|powershell - Shell type: bash, zsh, fish, powershell + bash|zsh Shell type: bash or zsh --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-aws-config-default-product.txt b/docs/help/floci-aws-config-default-product.txt index e1cacc7..cb1ef5f 100644 --- a/docs/help/floci-aws-config-default-product.txt +++ b/docs/help/floci-aws-config-default-product.txt @@ -1,12 +1,15 @@ -Usage: floci aws config default-product [-hqvV] [--no-color] [--container=] - [--endpoint=] [-o=text|json|yaml] [--profile=] - aws|az|gcp|oci +Usage: floci aws config default-product [-hqvV] [--json] [--no-color] [--no-emoji] + [--container=] [--endpoint=] [-o=text|json|yaml] + [--profile=] aws|az|gcp|oci Set the default product for bare commands like 'floci start' aws|az|gcp|oci Product to use by default: aws, az, gcp, oci --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-aws-config-profile.txt b/docs/help/floci-aws-config-profile.txt index 9cf64a9..9163e4e 100644 --- a/docs/help/floci-aws-config-profile.txt +++ b/docs/help/floci-aws-config-profile.txt @@ -1,18 +1,22 @@ -Usage: floci aws config profile [-hqvV] [--no-color] [--container=] [--endpoint=] - [--image=] [--namespace=] [-o=text|json|yaml] - [--persist=] [--port=] [--profile=] - [--services=] list|show|create|delete [] [COMMAND] +Usage: floci aws config profile [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [--image=] [--namespace=] + [-o=text|json|yaml] [--persist=] [--port=] + [--profile=] [--services=] list|show|create|edit|delete + [] [COMMAND] Manage Floci AWS configuration profiles - list|show|create|delete - Action: list, show, create, delete - [] Profile name (required for show, create, delete) + list|show|create|edit|delete + Action: list, show, create, edit, delete + [] Profile name (required for show, create, edit, delete) --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. --image= create: Docker image for this instance + --json Shorthand for --output json --namespace= create: Docker resource namespace for the containers this instance launches (default: derived from --container) --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --persist= create: host directory that keeps this instance's state diff --git a/docs/help/floci-aws-config-show.txt b/docs/help/floci-aws-config-show.txt index 54ac45c..9023d77 100644 --- a/docs/help/floci-aws-config-show.txt +++ b/docs/help/floci-aws-config-show.txt @@ -1,10 +1,13 @@ -Usage: floci aws config show [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci aws config show [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Show the active Floci AWS configuration --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-aws-config-validate.txt b/docs/help/floci-aws-config-validate.txt index 0488f23..71117c5 100644 --- a/docs/help/floci-aws-config-validate.txt +++ b/docs/help/floci-aws-config-validate.txt @@ -1,11 +1,15 @@ -Usage: floci aws config validate [-hqvV] [--no-color] [--container=] [--endpoint=] - [-f=] [-o=text|json|yaml] [--profile=] +Usage: floci aws config validate [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-f=] [-o=text|json|yaml] + [--profile=] Validate a docker-compose.yml file for Floci AWS compatibility --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -f, --file= Path to docker-compose file -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-aws-doctor.txt b/docs/help/floci-aws-doctor.txt index dbcca1d..c0528a6 100644 --- a/docs/help/floci-aws-doctor.txt +++ b/docs/help/floci-aws-doctor.txt @@ -1,11 +1,15 @@ -Usage: floci aws doctor [-hqvV] [--no-color] [--check=] [--container=] - [--endpoint=] [-o=text|json|yaml] [--profile=] +Usage: floci aws doctor [-hqvV] [--json] [--no-color] [--no-emoji] [--check=] + [--container=] [--endpoint=] [-o=text|json|yaml] + [--profile=] Run environment diagnostics for Floci AWS --check= Run only a specific check by name --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-aws-env.txt b/docs/help/floci-aws-env.txt index 5823ab7..47edba1 100644 --- a/docs/help/floci-aws-env.txt +++ b/docs/help/floci-aws-env.txt @@ -1,11 +1,15 @@ -Usage: floci aws env [-hqvV] [--no-color] [--container=] [--endpoint=] [--host=] - [-o=text|json|yaml] [--profile=] [--region=] [--shell=] +Usage: floci aws env [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [--host=] [-o=text|json|yaml] [--profile=] + [--region=] [--shell=] Print AWS environment variables to connect to Floci AWS --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. --host= Hostname for the AWS endpoint URL (default: localhost.floci.io) + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-aws-logs.txt b/docs/help/floci-aws-logs.txt index b71898b..d41aeea 100644 --- a/docs/help/floci-aws-logs.txt +++ b/docs/help/floci-aws-logs.txt @@ -1,12 +1,15 @@ -Usage: floci aws logs [-fhqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] [--service=] +Usage: floci aws logs [-fhqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] [--service=] [--since=] [--tail=] Fetch logs from the Floci AWS container --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -f, --follow Follow log output -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-aws-reset.txt b/docs/help/floci-aws-reset.txt index 33fd4b7..13b4a49 100644 --- a/docs/help/floci-aws-reset.txt +++ b/docs/help/floci-aws-reset.txt @@ -1,10 +1,13 @@ -Usage: floci aws reset [-hqvVy] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci aws reset [-hqvVy] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Delete every resource in the running Floci AWS instance, keeping it running --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-aws-restart.txt b/docs/help/floci-aws-restart.txt index 3d63fa4..141c86e 100644 --- a/docs/help/floci-aws-restart.txt +++ b/docs/help/floci-aws-restart.txt @@ -1,10 +1,13 @@ -Usage: floci aws restart [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci aws restart [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Stop and restart the Floci AWS container --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-aws-services.txt b/docs/help/floci-aws-services.txt index e6310a3..9077715 100644 --- a/docs/help/floci-aws-services.txt +++ b/docs/help/floci-aws-services.txt @@ -1,10 +1,13 @@ -Usage: floci aws services [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci aws services [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] List services available in the running Floci AWS instance --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-aws-snapshot-delete.txt b/docs/help/floci-aws-snapshot-delete.txt index 4972131..44d50fd 100644 --- a/docs/help/floci-aws-snapshot-delete.txt +++ b/docs/help/floci-aws-snapshot-delete.txt @@ -1,11 +1,14 @@ -Usage: floci aws snapshot delete [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci aws snapshot delete [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Delete a Floci AWS snapshot Snapshot name --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-aws-snapshot-export.txt b/docs/help/floci-aws-snapshot-export.txt index f0544a1..ba0e9e2 100644 --- a/docs/help/floci-aws-snapshot-export.txt +++ b/docs/help/floci-aws-snapshot-export.txt @@ -1,12 +1,16 @@ -Usage: floci aws snapshot export [-hqvV] [--no-color] [--container=] [--endpoint=] - -f= [-o=text|json|yaml] [--profile=] +Usage: floci aws snapshot export [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] -f= [-o=text|json|yaml] + [--profile=] Export a Floci AWS snapshot to a tarball file Snapshot name --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -f, --file= Destination file path -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-aws-snapshot-import.txt b/docs/help/floci-aws-snapshot-import.txt index d977de3..655b632 100644 --- a/docs/help/floci-aws-snapshot-import.txt +++ b/docs/help/floci-aws-snapshot-import.txt @@ -1,12 +1,16 @@ -Usage: floci aws snapshot import [-hqvV] [--no-color] [--container=] [--endpoint=] - -f= [--name=] [-o=text|json|yaml] [--profile=] +Usage: floci aws snapshot import [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] -f= [--name=] [-o=text|json|yaml] + [--profile=] Import a Floci AWS snapshot from a tarball file --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -f, --file= Source tarball path -h, --help Show this help message and exit. + --json Shorthand for --output json --name= Name for the imported snapshot --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-aws-snapshot-list.txt b/docs/help/floci-aws-snapshot-list.txt index d29dccd..25d2625 100644 --- a/docs/help/floci-aws-snapshot-list.txt +++ b/docs/help/floci-aws-snapshot-list.txt @@ -1,10 +1,13 @@ -Usage: floci aws snapshot list [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci aws snapshot list [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] List available Floci AWS snapshots --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-aws-snapshot-load.txt b/docs/help/floci-aws-snapshot-load.txt index a36337d..1f8a339 100644 --- a/docs/help/floci-aws-snapshot-load.txt +++ b/docs/help/floci-aws-snapshot-load.txt @@ -1,11 +1,14 @@ -Usage: floci aws snapshot load [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci aws snapshot load [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Load a Floci AWS snapshot Snapshot name --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-aws-snapshot-save.txt b/docs/help/floci-aws-snapshot-save.txt index 50e904c..0e39a77 100644 --- a/docs/help/floci-aws-snapshot-save.txt +++ b/docs/help/floci-aws-snapshot-save.txt @@ -1,12 +1,16 @@ -Usage: floci aws snapshot save [-hqvV] [--no-color] [--container=] [--endpoint=] - [-m=] [-o=text|json|yaml] [--profile=] +Usage: floci aws snapshot save [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-m=] [-o=text|json|yaml] + [--profile=] Save the current Floci AWS state as a named snapshot Snapshot name --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json -m, --message= Optional description --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-aws-start.txt b/docs/help/floci-aws-start.txt index 46fc41c..0355605 100644 --- a/docs/help/floci-aws-start.txt +++ b/docs/help/floci-aws-start.txt @@ -1,16 +1,19 @@ -Usage: floci aws start [-hqvV] [--detach] [--no-color] [--container=] [--endpoint=] - [--image=] [--namespace=] [-o=text|json|yaml] [--persist=] - [--port=] [--profile=] [--pull=always|missing|never] - [--services=] +Usage: floci aws start [-hqvV] [--detach] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [--image=] [--namespace=] [-o=text|json|yaml] + [--persist=] [--port=] [--profile=] + [--pull=always|missing|never] [--services=] Start the Floci AWS emulator container --container= Floci container name (default: floci) --detach Return immediately without waiting for readiness --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. --image= Image reference to use (default: floci/floci:latest) + --json Shorthand for --output json --namespace= Docker resource namespace for the containers this instance launches (default: derived from --container; none for the default container) --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --persist= Host directory for persistent state diff --git a/docs/help/floci-aws-status.txt b/docs/help/floci-aws-status.txt index 62fc7be..0674257 100644 --- a/docs/help/floci-aws-status.txt +++ b/docs/help/floci-aws-status.txt @@ -1,10 +1,13 @@ -Usage: floci aws status [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci aws status [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Show Floci AWS container and server status --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-aws-stop.txt b/docs/help/floci-aws-stop.txt index d987770..fc5e2b3 100644 --- a/docs/help/floci-aws-stop.txt +++ b/docs/help/floci-aws-stop.txt @@ -1,10 +1,14 @@ -Usage: floci aws stop [-hqrvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] [--timeout=] +Usage: floci aws stop [-hqrvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] + [--timeout=] Stop the Floci AWS container --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-aws-version.txt b/docs/help/floci-aws-version.txt index 1090af4..7c8fbdc 100644 --- a/docs/help/floci-aws-version.txt +++ b/docs/help/floci-aws-version.txt @@ -1,10 +1,13 @@ -Usage: floci aws version [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci aws version [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Show CLI version, connected Floci AWS server version, and image digest --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-aws-wait.txt b/docs/help/floci-aws-wait.txt index 253bb8c..7389a01 100644 --- a/docs/help/floci-aws-wait.txt +++ b/docs/help/floci-aws-wait.txt @@ -1,11 +1,14 @@ -Usage: floci aws wait [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] [--service=] +Usage: floci aws wait [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] [--service=] [--timeout=] Wait until Floci AWS is ready to accept requests --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-az-completion.txt b/docs/help/floci-az-completion.txt index d62ae50..6c1ede3 100644 --- a/docs/help/floci-az-completion.txt +++ b/docs/help/floci-az-completion.txt @@ -1,12 +1,14 @@ -Usage: floci az completion [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] bash|zsh|fish|powershell +Usage: floci az completion [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] bash|zsh Generate shell completion scripts - bash|zsh|fish|powershell - Shell type: bash, zsh, fish, powershell + bash|zsh Shell type: bash or zsh --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-az-config-profile.txt b/docs/help/floci-az-config-profile.txt index fff7a52..68ce1bc 100644 --- a/docs/help/floci-az-config-profile.txt +++ b/docs/help/floci-az-config-profile.txt @@ -1,18 +1,22 @@ -Usage: floci az config profile [-hqvV] [--no-color] [--container=] [--endpoint=] - [--image=] [--namespace=] [-o=text|json|yaml] - [--persist=] [--port=] [--profile=] - [--services=] list|show|create|delete [] [COMMAND] +Usage: floci az config profile [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [--image=] [--namespace=] + [-o=text|json|yaml] [--persist=] [--port=] + [--profile=] [--services=] list|show|create|edit|delete + [] [COMMAND] Manage Floci Azure configuration profiles - list|show|create|delete - Action: list, show, create, delete - [] Profile name (required for show, create, delete) + list|show|create|edit|delete + Action: list, show, create, edit, delete + [] Profile name (required for show, create, edit, delete) --container= Floci container name (default: floci-az) --endpoint= Floci server endpoint URL (default: http://localhost:4577) -h, --help Show this help message and exit. --image= create: Docker image for this instance + --json Shorthand for --output json --namespace= create: Docker resource namespace for the containers this instance launches (default: derived from --container) --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --persist= create: host directory that keeps this instance's state diff --git a/docs/help/floci-az-config-show.txt b/docs/help/floci-az-config-show.txt index 8de5472..9761a07 100644 --- a/docs/help/floci-az-config-show.txt +++ b/docs/help/floci-az-config-show.txt @@ -1,10 +1,13 @@ -Usage: floci az config show [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci az config show [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Show the active Floci Azure configuration --container= Floci container name (default: floci-az) --endpoint= Floci server endpoint URL (default: http://localhost:4577) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-az-config-validate.txt b/docs/help/floci-az-config-validate.txt index b6adeda..11a8cf0 100644 --- a/docs/help/floci-az-config-validate.txt +++ b/docs/help/floci-az-config-validate.txt @@ -1,11 +1,15 @@ -Usage: floci az config validate [-hqvV] [--no-color] [--container=] [--endpoint=] - [-f=] [-o=text|json|yaml] [--profile=] +Usage: floci az config validate [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-f=] [-o=text|json|yaml] + [--profile=] Validate a docker-compose.yml file for Floci Azure compatibility --container= Floci container name (default: floci-az) --endpoint= Floci server endpoint URL (default: http://localhost:4577) -f, --file= Path to docker-compose file -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-az-doctor.txt b/docs/help/floci-az-doctor.txt index a80be9e..b058922 100644 --- a/docs/help/floci-az-doctor.txt +++ b/docs/help/floci-az-doctor.txt @@ -1,11 +1,15 @@ -Usage: floci az doctor [-hqvV] [--no-color] [--check=] [--container=] - [--endpoint=] [-o=text|json|yaml] [--profile=] +Usage: floci az doctor [-hqvV] [--json] [--no-color] [--no-emoji] [--check=] + [--container=] [--endpoint=] [-o=text|json|yaml] + [--profile=] Run environment diagnostics for Floci Azure --check= Run only a specific check by name --container= Floci container name (default: floci-az) --endpoint= Floci server endpoint URL (default: http://localhost:4577) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-az-env.txt b/docs/help/floci-az-env.txt index 32066a4..4051997 100644 --- a/docs/help/floci-az-env.txt +++ b/docs/help/floci-az-env.txt @@ -1,6 +1,7 @@ -Usage: floci az env [-hqvV] [--no-color] [--account=] [--container=] [--endpoint=] - [--format=connection-string|sdk-vars] [--host=] [-o=text|json|yaml] - [--profile=] [--service=] [--shell=] +Usage: floci az env [-hqvV] [--json] [--no-color] [--no-emoji] [--account=] + [--container=] [--endpoint=] [--format=connection-string|sdk-vars] + [--host=] [-o=text|json|yaml] [--profile=] [--service=] + [--shell=] Print Azure environment variables to connect to Floci Azure --account= Storage account name (default: devstoreaccount1) --container= Floci container name (default: floci-az) @@ -9,7 +10,10 @@ Print Azure environment variables to connect to Floci Azure Output mode: connection-string, sdk-vars (default: connection-string) -h, --help Show this help message and exit. --host= Hostname for endpoint URLs (default: localhost.floci.io) + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-az-logs.txt b/docs/help/floci-az-logs.txt index 1e2ce98..9b885e3 100644 --- a/docs/help/floci-az-logs.txt +++ b/docs/help/floci-az-logs.txt @@ -1,12 +1,15 @@ -Usage: floci az logs [-fhqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] [--service=] [--since=] - [--tail=] +Usage: floci az logs [-fhqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] [--service=] + [--since=] [--tail=] Fetch logs from the Floci Azure container --container= Floci container name (default: floci-az) --endpoint= Floci server endpoint URL (default: http://localhost:4577) -f, --follow Follow log output -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-az-reset.txt b/docs/help/floci-az-reset.txt index 12e41ce..1f4008c 100644 --- a/docs/help/floci-az-reset.txt +++ b/docs/help/floci-az-reset.txt @@ -1,10 +1,13 @@ -Usage: floci az reset [-hqvVy] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci az reset [-hqvVy] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Delete every resource in the running Floci Azure instance, keeping it running --container= Floci container name (default: floci-az) --endpoint= Floci server endpoint URL (default: http://localhost:4577) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-az-restart.txt b/docs/help/floci-az-restart.txt index a755b99..cf3d77b 100644 --- a/docs/help/floci-az-restart.txt +++ b/docs/help/floci-az-restart.txt @@ -1,10 +1,13 @@ -Usage: floci az restart [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci az restart [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Stop and restart the Floci Azure container --container= Floci container name (default: floci-az) --endpoint= Floci server endpoint URL (default: http://localhost:4577) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-az-services.txt b/docs/help/floci-az-services.txt index 91658f2..2caa721 100644 --- a/docs/help/floci-az-services.txt +++ b/docs/help/floci-az-services.txt @@ -1,10 +1,13 @@ -Usage: floci az services [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci az services [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] List services available in the running Floci Azure instance --container= Floci container name (default: floci-az) --endpoint= Floci server endpoint URL (default: http://localhost:4577) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-az-setup.txt b/docs/help/floci-az-setup.txt index d4c5fac..21ab9d8 100644 --- a/docs/help/floci-az-setup.txt +++ b/docs/help/floci-az-setup.txt @@ -1,6 +1,7 @@ -Usage: floci az setup [-hqvV] [--global] [--no-color] [--reset] [--client-id=] - [--client-secret=] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] [--subscription=] [--tenant=] +Usage: floci az setup [-hqvV] [--global] [--json] [--no-color] [--no-emoji] [--reset] + [--client-id=] [--client-secret=] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] + [--subscription=] [--tenant=] Point the az CLI at Floci Azure: trust its certificate, register the cloud and log in --client-id= Service principal client id (default: 00000000-0000-0000-0000-000000000003) @@ -12,7 +13,10 @@ Point the az CLI at Floci Azure: trust its certificate, register the cloud and l --global Configure your default az config (~/.azure) instead of an isolated one under ~/.floci/az -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-az-snapshot-delete.txt b/docs/help/floci-az-snapshot-delete.txt index 6157139..32b1d2c 100644 --- a/docs/help/floci-az-snapshot-delete.txt +++ b/docs/help/floci-az-snapshot-delete.txt @@ -1,11 +1,14 @@ -Usage: floci az snapshot delete [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci az snapshot delete [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Delete a Floci Azure snapshot Snapshot name --container= Floci container name (default: floci-az) --endpoint= Floci server endpoint URL (default: http://localhost:4577) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-az-snapshot-export.txt b/docs/help/floci-az-snapshot-export.txt index be16a84..23e5de5 100644 --- a/docs/help/floci-az-snapshot-export.txt +++ b/docs/help/floci-az-snapshot-export.txt @@ -1,12 +1,16 @@ -Usage: floci az snapshot export [-hqvV] [--no-color] [--container=] [--endpoint=] - -f= [-o=text|json|yaml] [--profile=] +Usage: floci az snapshot export [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] -f= [-o=text|json|yaml] [--profile=] + Export a Floci Azure snapshot to a tarball file Snapshot name --container= Floci container name (default: floci-az) --endpoint= Floci server endpoint URL (default: http://localhost:4577) -f, --file= Destination file path -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-az-snapshot-import.txt b/docs/help/floci-az-snapshot-import.txt index 8de83b4..0c152ac 100644 --- a/docs/help/floci-az-snapshot-import.txt +++ b/docs/help/floci-az-snapshot-import.txt @@ -1,12 +1,16 @@ -Usage: floci az snapshot import [-hqvV] [--no-color] [--container=] [--endpoint=] - -f= [--name=] [-o=text|json|yaml] [--profile=] +Usage: floci az snapshot import [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] -f= [--name=] [-o=text|json|yaml] + [--profile=] Import a Floci Azure snapshot from a tarball file --container= Floci container name (default: floci-az) --endpoint= Floci server endpoint URL (default: http://localhost:4577) -f, --file= Source tarball path -h, --help Show this help message and exit. + --json Shorthand for --output json --name= Name for the imported snapshot --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-az-snapshot-list.txt b/docs/help/floci-az-snapshot-list.txt index de0638e..695acc7 100644 --- a/docs/help/floci-az-snapshot-list.txt +++ b/docs/help/floci-az-snapshot-list.txt @@ -1,10 +1,13 @@ -Usage: floci az snapshot list [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci az snapshot list [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] List available Floci Azure snapshots --container= Floci container name (default: floci-az) --endpoint= Floci server endpoint URL (default: http://localhost:4577) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-az-snapshot-load.txt b/docs/help/floci-az-snapshot-load.txt index 8977a09..6a14af6 100644 --- a/docs/help/floci-az-snapshot-load.txt +++ b/docs/help/floci-az-snapshot-load.txt @@ -1,11 +1,14 @@ -Usage: floci az snapshot load [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci az snapshot load [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Load a Floci Azure snapshot Snapshot name --container= Floci container name (default: floci-az) --endpoint= Floci server endpoint URL (default: http://localhost:4577) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-az-snapshot-save.txt b/docs/help/floci-az-snapshot-save.txt index 9d83747..ca8f9fc 100644 --- a/docs/help/floci-az-snapshot-save.txt +++ b/docs/help/floci-az-snapshot-save.txt @@ -1,12 +1,16 @@ -Usage: floci az snapshot save [-hqvV] [--no-color] [--container=] [--endpoint=] - [-m=] [-o=text|json|yaml] [--profile=] +Usage: floci az snapshot save [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-m=] [-o=text|json|yaml] [--profile=] + Save the current Floci Azure state as a named snapshot Snapshot name --container= Floci container name (default: floci-az) --endpoint= Floci server endpoint URL (default: http://localhost:4577) -h, --help Show this help message and exit. + --json Shorthand for --output json -m, --message= Optional description --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-az-start.txt b/docs/help/floci-az-start.txt index 77e7ee3..ce12c02 100644 --- a/docs/help/floci-az-start.txt +++ b/docs/help/floci-az-start.txt @@ -1,16 +1,19 @@ -Usage: floci az start [-hqvV] [--detach] [--no-color] [--container=] [--endpoint=] - [--image=] [--namespace=] [-o=text|json|yaml] [--persist=] - [--port=] [--profile=] [--pull=always|missing|never] - [--services=] +Usage: floci az start [-hqvV] [--detach] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [--image=] [--namespace=] [-o=text|json|yaml] + [--persist=] [--port=] [--profile=] + [--pull=always|missing|never] [--services=] Start the Floci Azure emulator container --container= Floci container name (default: floci-az) --detach Return immediately without waiting for readiness --endpoint= Floci server endpoint URL (default: http://localhost:4577) -h, --help Show this help message and exit. --image= Image reference to use (default: floci/floci-az:latest) + --json Shorthand for --output json --namespace= Docker resource namespace for the containers this instance launches (default: derived from --container; none for the default container) --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --persist= Host directory for persistent state diff --git a/docs/help/floci-az-status.txt b/docs/help/floci-az-status.txt index 41bf1a6..0c47df8 100644 --- a/docs/help/floci-az-status.txt +++ b/docs/help/floci-az-status.txt @@ -1,10 +1,13 @@ -Usage: floci az status [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci az status [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Show Floci Azure container and server status --container= Floci container name (default: floci-az) --endpoint= Floci server endpoint URL (default: http://localhost:4577) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-az-stop.txt b/docs/help/floci-az-stop.txt index 0eebb9d..1bad530 100644 --- a/docs/help/floci-az-stop.txt +++ b/docs/help/floci-az-stop.txt @@ -1,10 +1,13 @@ -Usage: floci az stop [-hqrvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] [--timeout=] +Usage: floci az stop [-hqrvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] [--timeout=] Stop the Floci Azure container --container= Floci container name (default: floci-az) --endpoint= Floci server endpoint URL (default: http://localhost:4577) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-az-version.txt b/docs/help/floci-az-version.txt index 77a3737..57e85f4 100644 --- a/docs/help/floci-az-version.txt +++ b/docs/help/floci-az-version.txt @@ -1,10 +1,13 @@ -Usage: floci az version [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci az version [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Show CLI version, connected Floci Azure server version, and image digest --container= Floci container name (default: floci-az) --endpoint= Floci server endpoint URL (default: http://localhost:4577) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-az-wait.txt b/docs/help/floci-az-wait.txt index a91d8a0..63f8ccb 100644 --- a/docs/help/floci-az-wait.txt +++ b/docs/help/floci-az-wait.txt @@ -1,11 +1,14 @@ -Usage: floci az wait [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] [--service=] +Usage: floci az wait [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] [--service=] [--timeout=] Wait until Floci Azure is ready to accept requests --container= Floci container name (default: floci-az) --endpoint= Floci server endpoint URL (default: http://localhost:4577) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-completion.txt b/docs/help/floci-completion.txt index 91c0dc8..830e7eb 100644 --- a/docs/help/floci-completion.txt +++ b/docs/help/floci-completion.txt @@ -1,12 +1,14 @@ -Usage: floci completion [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] bash|zsh|fish|powershell +Usage: floci completion [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] bash|zsh Generate shell completion scripts - bash|zsh|fish|powershell - Shell type: bash, zsh, fish, powershell + bash|zsh Shell type: bash or zsh --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-config-default-product.txt b/docs/help/floci-config-default-product.txt index f67c571..e97cf48 100644 --- a/docs/help/floci-config-default-product.txt +++ b/docs/help/floci-config-default-product.txt @@ -1,11 +1,15 @@ -Usage: floci config default-product [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] aws|az|gcp|oci +Usage: floci config default-product [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] + aws|az|gcp|oci Set the default product for bare commands like 'floci start' aws|az|gcp|oci Product to use by default: aws, az, gcp, oci --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-config-profile.txt b/docs/help/floci-config-profile.txt index b327e01..4dd43bd 100644 --- a/docs/help/floci-config-profile.txt +++ b/docs/help/floci-config-profile.txt @@ -1,18 +1,22 @@ -Usage: floci config profile [-hqvV] [--no-color] [--container=] [--endpoint=] - [--image=] [--namespace=] [-o=text|json|yaml] - [--persist=] [--port=] [--profile=] [--services=] - list|show|create|delete [] [COMMAND] +Usage: floci config profile [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [--image=] [--namespace=] + [-o=text|json|yaml] [--persist=] [--port=] + [--profile=] [--services=] list|show|create|edit|delete + [] [COMMAND] Manage Floci AWS configuration profiles - list|show|create|delete - Action: list, show, create, delete - [] Profile name (required for show, create, delete) + list|show|create|edit|delete + Action: list, show, create, edit, delete + [] Profile name (required for show, create, edit, delete) --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. --image= create: Docker image for this instance + --json Shorthand for --output json --namespace= create: Docker resource namespace for the containers this instance launches (default: derived from --container) --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --persist= create: host directory that keeps this instance's state diff --git a/docs/help/floci-config-show.txt b/docs/help/floci-config-show.txt index 92b0831..6345948 100644 --- a/docs/help/floci-config-show.txt +++ b/docs/help/floci-config-show.txt @@ -1,10 +1,13 @@ -Usage: floci config show [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci config show [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Show the active Floci AWS configuration --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-config-validate.txt b/docs/help/floci-config-validate.txt index 8c91233..f68ac49 100644 --- a/docs/help/floci-config-validate.txt +++ b/docs/help/floci-config-validate.txt @@ -1,11 +1,14 @@ -Usage: floci config validate [-hqvV] [--no-color] [--container=] [--endpoint=] - [-f=] [-o=text|json|yaml] [--profile=] +Usage: floci config validate [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-f=] [-o=text|json|yaml] [--profile=] Validate a docker-compose.yml file for Floci AWS compatibility --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -f, --file= Path to docker-compose file -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-doctor.txt b/docs/help/floci-doctor.txt index 78b8487..d51e403 100644 --- a/docs/help/floci-doctor.txt +++ b/docs/help/floci-doctor.txt @@ -1,11 +1,14 @@ -Usage: floci doctor [-hqvV] [--no-color] [--check=] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci doctor [-hqvV] [--json] [--no-color] [--no-emoji] [--check=] + [--container=] [--endpoint=] [-o=text|json|yaml] [--profile=] Run environment diagnostics for Floci AWS --check= Run only a specific check by name --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-env.txt b/docs/help/floci-env.txt index 41a40f2..7f2c72a 100644 --- a/docs/help/floci-env.txt +++ b/docs/help/floci-env.txt @@ -1,11 +1,15 @@ -Usage: floci env [-hqvV] [--no-color] [--container=] [--endpoint=] [--host=] - [-o=text|json|yaml] [--profile=] [--region=] [--shell=] +Usage: floci env [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] [--endpoint=] + [--host=] [-o=text|json|yaml] [--profile=] [--region=] + [--shell=] Print AWS environment variables to connect to Floci AWS --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. --host= Hostname for the AWS endpoint URL (default: localhost.floci.io) + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-gcp-completion.txt b/docs/help/floci-gcp-completion.txt index 292febc..5e475ca 100644 --- a/docs/help/floci-gcp-completion.txt +++ b/docs/help/floci-gcp-completion.txt @@ -1,12 +1,14 @@ -Usage: floci gcp completion [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] bash|zsh|fish|powershell +Usage: floci gcp completion [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] bash|zsh Generate shell completion scripts - bash|zsh|fish|powershell - Shell type: bash, zsh, fish, powershell + bash|zsh Shell type: bash or zsh --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-gcp-config-profile.txt b/docs/help/floci-gcp-config-profile.txt index 9dc5ab8..da3d6be 100644 --- a/docs/help/floci-gcp-config-profile.txt +++ b/docs/help/floci-gcp-config-profile.txt @@ -1,18 +1,22 @@ -Usage: floci gcp config profile [-hqvV] [--no-color] [--container=] [--endpoint=] - [--image=] [--namespace=] [-o=text|json|yaml] - [--persist=] [--port=] [--profile=] - [--services=] list|show|create|delete [] [COMMAND] +Usage: floci gcp config profile [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [--image=] [--namespace=] + [-o=text|json|yaml] [--persist=] [--port=] + [--profile=] [--services=] list|show|create|edit|delete + [] [COMMAND] Manage Floci GCP configuration profiles - list|show|create|delete - Action: list, show, create, delete - [] Profile name (required for show, create, delete) + list|show|create|edit|delete + Action: list, show, create, edit, delete + [] Profile name (required for show, create, edit, delete) --container= Floci container name (default: floci-gcp) --endpoint= Floci server endpoint URL (default: http://localhost:4588) -h, --help Show this help message and exit. --image= create: Docker image for this instance + --json Shorthand for --output json --namespace= create: Docker resource namespace for the containers this instance launches (default: derived from --container) --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --persist= create: host directory that keeps this instance's state diff --git a/docs/help/floci-gcp-config-show.txt b/docs/help/floci-gcp-config-show.txt index a40bd20..58e6558 100644 --- a/docs/help/floci-gcp-config-show.txt +++ b/docs/help/floci-gcp-config-show.txt @@ -1,10 +1,13 @@ -Usage: floci gcp config show [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci gcp config show [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Show the active Floci GCP configuration --container= Floci container name (default: floci-gcp) --endpoint= Floci server endpoint URL (default: http://localhost:4588) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-gcp-config-validate.txt b/docs/help/floci-gcp-config-validate.txt index 5330b80..a20c122 100644 --- a/docs/help/floci-gcp-config-validate.txt +++ b/docs/help/floci-gcp-config-validate.txt @@ -1,11 +1,15 @@ -Usage: floci gcp config validate [-hqvV] [--no-color] [--container=] [--endpoint=] - [-f=] [-o=text|json|yaml] [--profile=] +Usage: floci gcp config validate [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-f=] [-o=text|json|yaml] + [--profile=] Validate a docker-compose.yml file for Floci GCP compatibility --container= Floci container name (default: floci-gcp) --endpoint= Floci server endpoint URL (default: http://localhost:4588) -f, --file= Path to docker-compose file -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-gcp-doctor.txt b/docs/help/floci-gcp-doctor.txt index e0be98b..bb42c0d 100644 --- a/docs/help/floci-gcp-doctor.txt +++ b/docs/help/floci-gcp-doctor.txt @@ -1,11 +1,15 @@ -Usage: floci gcp doctor [-hqvV] [--no-color] [--check=] [--container=] - [--endpoint=] [-o=text|json|yaml] [--profile=] +Usage: floci gcp doctor [-hqvV] [--json] [--no-color] [--no-emoji] [--check=] + [--container=] [--endpoint=] [-o=text|json|yaml] + [--profile=] Run environment diagnostics for Floci GCP --check= Run only a specific check by name --container= Floci container name (default: floci-gcp) --endpoint= Floci server endpoint URL (default: http://localhost:4588) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-gcp-env.txt b/docs/help/floci-gcp-env.txt index d97de80..da9a06c 100644 --- a/docs/help/floci-gcp-env.txt +++ b/docs/help/floci-gcp-env.txt @@ -1,10 +1,14 @@ -Usage: floci gcp env [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] [--service=] [--shell=] +Usage: floci gcp env [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] [--service=] + [--shell=] Print GCP environment variables to connect to Floci GCP --container= Floci container name (default: floci-gcp) --endpoint= Floci server endpoint URL (default: http://localhost:4588) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-gcp-logs.txt b/docs/help/floci-gcp-logs.txt index 8cbdcdb..ec24c4b 100644 --- a/docs/help/floci-gcp-logs.txt +++ b/docs/help/floci-gcp-logs.txt @@ -1,12 +1,15 @@ -Usage: floci gcp logs [-fhqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] [--service=] +Usage: floci gcp logs [-fhqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] [--service=] [--since=] [--tail=] Fetch logs from the Floci GCP container --container= Floci container name (default: floci-gcp) --endpoint= Floci server endpoint URL (default: http://localhost:4588) -f, --follow Follow log output -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-gcp-reset.txt b/docs/help/floci-gcp-reset.txt index 690d505..5ac7cb5 100644 --- a/docs/help/floci-gcp-reset.txt +++ b/docs/help/floci-gcp-reset.txt @@ -1,10 +1,13 @@ -Usage: floci gcp reset [-hqvVy] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci gcp reset [-hqvVy] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Delete every resource in the running Floci GCP instance, keeping it running --container= Floci container name (default: floci-gcp) --endpoint= Floci server endpoint URL (default: http://localhost:4588) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-gcp-restart.txt b/docs/help/floci-gcp-restart.txt index f74fb29..82cceab 100644 --- a/docs/help/floci-gcp-restart.txt +++ b/docs/help/floci-gcp-restart.txt @@ -1,10 +1,13 @@ -Usage: floci gcp restart [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci gcp restart [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Stop and restart the Floci GCP container --container= Floci container name (default: floci-gcp) --endpoint= Floci server endpoint URL (default: http://localhost:4588) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-gcp-services.txt b/docs/help/floci-gcp-services.txt index 0746fce..b8fafa7 100644 --- a/docs/help/floci-gcp-services.txt +++ b/docs/help/floci-gcp-services.txt @@ -1,10 +1,13 @@ -Usage: floci gcp services [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci gcp services [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] List services available in the running Floci GCP instance --container= Floci container name (default: floci-gcp) --endpoint= Floci server endpoint URL (default: http://localhost:4588) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-gcp-snapshot-delete.txt b/docs/help/floci-gcp-snapshot-delete.txt index e6f94c7..5668e3e 100644 --- a/docs/help/floci-gcp-snapshot-delete.txt +++ b/docs/help/floci-gcp-snapshot-delete.txt @@ -1,11 +1,14 @@ -Usage: floci gcp snapshot delete [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci gcp snapshot delete [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Delete a Floci GCP snapshot Snapshot name --container= Floci container name (default: floci-gcp) --endpoint= Floci server endpoint URL (default: http://localhost:4588) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-gcp-snapshot-export.txt b/docs/help/floci-gcp-snapshot-export.txt index 404ec8a..83f9124 100644 --- a/docs/help/floci-gcp-snapshot-export.txt +++ b/docs/help/floci-gcp-snapshot-export.txt @@ -1,12 +1,16 @@ -Usage: floci gcp snapshot export [-hqvV] [--no-color] [--container=] [--endpoint=] - -f= [-o=text|json|yaml] [--profile=] +Usage: floci gcp snapshot export [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] -f= [-o=text|json|yaml] + [--profile=] Export a Floci GCP snapshot to a tarball file Snapshot name --container= Floci container name (default: floci-gcp) --endpoint= Floci server endpoint URL (default: http://localhost:4588) -f, --file= Destination file path -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-gcp-snapshot-import.txt b/docs/help/floci-gcp-snapshot-import.txt index 386a38e..91ac5cf 100644 --- a/docs/help/floci-gcp-snapshot-import.txt +++ b/docs/help/floci-gcp-snapshot-import.txt @@ -1,12 +1,16 @@ -Usage: floci gcp snapshot import [-hqvV] [--no-color] [--container=] [--endpoint=] - -f= [--name=] [-o=text|json|yaml] [--profile=] +Usage: floci gcp snapshot import [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] -f= [--name=] [-o=text|json|yaml] + [--profile=] Import a Floci GCP snapshot from a tarball file --container= Floci container name (default: floci-gcp) --endpoint= Floci server endpoint URL (default: http://localhost:4588) -f, --file= Source tarball path -h, --help Show this help message and exit. + --json Shorthand for --output json --name= Name for the imported snapshot --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-gcp-snapshot-list.txt b/docs/help/floci-gcp-snapshot-list.txt index 4fc051d..ab538f9 100644 --- a/docs/help/floci-gcp-snapshot-list.txt +++ b/docs/help/floci-gcp-snapshot-list.txt @@ -1,10 +1,13 @@ -Usage: floci gcp snapshot list [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci gcp snapshot list [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] List available Floci GCP snapshots --container= Floci container name (default: floci-gcp) --endpoint= Floci server endpoint URL (default: http://localhost:4588) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-gcp-snapshot-load.txt b/docs/help/floci-gcp-snapshot-load.txt index a324264..fd881f1 100644 --- a/docs/help/floci-gcp-snapshot-load.txt +++ b/docs/help/floci-gcp-snapshot-load.txt @@ -1,11 +1,14 @@ -Usage: floci gcp snapshot load [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci gcp snapshot load [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Load a Floci GCP snapshot Snapshot name --container= Floci container name (default: floci-gcp) --endpoint= Floci server endpoint URL (default: http://localhost:4588) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-gcp-snapshot-save.txt b/docs/help/floci-gcp-snapshot-save.txt index 7d695c9..d602beb 100644 --- a/docs/help/floci-gcp-snapshot-save.txt +++ b/docs/help/floci-gcp-snapshot-save.txt @@ -1,12 +1,16 @@ -Usage: floci gcp snapshot save [-hqvV] [--no-color] [--container=] [--endpoint=] - [-m=] [-o=text|json|yaml] [--profile=] +Usage: floci gcp snapshot save [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-m=] [-o=text|json|yaml] + [--profile=] Save the current Floci GCP state as a named snapshot Snapshot name --container= Floci container name (default: floci-gcp) --endpoint= Floci server endpoint URL (default: http://localhost:4588) -h, --help Show this help message and exit. + --json Shorthand for --output json -m, --message= Optional description --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-gcp-start.txt b/docs/help/floci-gcp-start.txt index d800795..a10aa40 100644 --- a/docs/help/floci-gcp-start.txt +++ b/docs/help/floci-gcp-start.txt @@ -1,16 +1,19 @@ -Usage: floci gcp start [-hqvV] [--detach] [--no-color] [--container=] [--endpoint=] - [--image=] [--namespace=] [-o=text|json|yaml] [--persist=] - [--port=] [--profile=] [--pull=always|missing|never] - [--services=] +Usage: floci gcp start [-hqvV] [--detach] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [--image=] [--namespace=] [-o=text|json|yaml] + [--persist=] [--port=] [--profile=] + [--pull=always|missing|never] [--services=] Start the Floci GCP emulator container --container= Floci container name (default: floci-gcp) --detach Return immediately without waiting for readiness --endpoint= Floci server endpoint URL (default: http://localhost:4588) -h, --help Show this help message and exit. --image= Image reference to use (default: floci/floci-gcp:latest) + --json Shorthand for --output json --namespace= Docker resource namespace for the containers this instance launches (default: derived from --container; none for the default container) --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --persist= Host directory for persistent state diff --git a/docs/help/floci-gcp-status.txt b/docs/help/floci-gcp-status.txt index 169822a..8384235 100644 --- a/docs/help/floci-gcp-status.txt +++ b/docs/help/floci-gcp-status.txt @@ -1,10 +1,13 @@ -Usage: floci gcp status [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci gcp status [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Show Floci GCP container and server status --container= Floci container name (default: floci-gcp) --endpoint= Floci server endpoint URL (default: http://localhost:4588) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-gcp-stop.txt b/docs/help/floci-gcp-stop.txt index 046febb..ec6e2ee 100644 --- a/docs/help/floci-gcp-stop.txt +++ b/docs/help/floci-gcp-stop.txt @@ -1,10 +1,14 @@ -Usage: floci gcp stop [-hqrvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] [--timeout=] +Usage: floci gcp stop [-hqrvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] + [--timeout=] Stop the Floci GCP container --container= Floci container name (default: floci-gcp) --endpoint= Floci server endpoint URL (default: http://localhost:4588) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-gcp-version.txt b/docs/help/floci-gcp-version.txt index b346e10..65bba19 100644 --- a/docs/help/floci-gcp-version.txt +++ b/docs/help/floci-gcp-version.txt @@ -1,10 +1,13 @@ -Usage: floci gcp version [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci gcp version [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Show CLI version, connected Floci GCP server version, and image digest --container= Floci container name (default: floci-gcp) --endpoint= Floci server endpoint URL (default: http://localhost:4588) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-gcp-wait.txt b/docs/help/floci-gcp-wait.txt index 6de43f3..73fa3d2 100644 --- a/docs/help/floci-gcp-wait.txt +++ b/docs/help/floci-gcp-wait.txt @@ -1,11 +1,14 @@ -Usage: floci gcp wait [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] [--service=] +Usage: floci gcp wait [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] [--service=] [--timeout=] Wait until Floci GCP is ready to accept requests --container= Floci container name (default: floci-gcp) --endpoint= Floci server endpoint URL (default: http://localhost:4588) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-logs.txt b/docs/help/floci-logs.txt index 3aa6cfe..042c745 100644 --- a/docs/help/floci-logs.txt +++ b/docs/help/floci-logs.txt @@ -1,11 +1,15 @@ -Usage: floci logs [-fhqvV] [--no-color] [--container=] [--endpoint=] [-o=text|json|yaml] - [--profile=] [--service=] [--since=] [--tail=] +Usage: floci logs [-fhqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] [--service=] + [--since=] [--tail=] Fetch logs from the Floci AWS container --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -f, --follow Follow log output -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-oci-completion.txt b/docs/help/floci-oci-completion.txt index d0ad089..4de125f 100644 --- a/docs/help/floci-oci-completion.txt +++ b/docs/help/floci-oci-completion.txt @@ -1,12 +1,14 @@ -Usage: floci oci completion [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] bash|zsh|fish|powershell +Usage: floci oci completion [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] bash|zsh Generate shell completion scripts - bash|zsh|fish|powershell - Shell type: bash, zsh, fish, powershell + bash|zsh Shell type: bash or zsh --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-oci-config-profile.txt b/docs/help/floci-oci-config-profile.txt index d7c3794..5913388 100644 --- a/docs/help/floci-oci-config-profile.txt +++ b/docs/help/floci-oci-config-profile.txt @@ -1,18 +1,22 @@ -Usage: floci oci config profile [-hqvV] [--no-color] [--container=] [--endpoint=] - [--image=] [--namespace=] [-o=text|json|yaml] - [--persist=] [--port=] [--profile=] - [--services=] list|show|create|delete [] [COMMAND] +Usage: floci oci config profile [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [--image=] [--namespace=] + [-o=text|json|yaml] [--persist=] [--port=] + [--profile=] [--services=] list|show|create|edit|delete + [] [COMMAND] Manage Floci OCI configuration profiles - list|show|create|delete - Action: list, show, create, delete - [] Profile name (required for show, create, delete) + list|show|create|edit|delete + Action: list, show, create, edit, delete + [] Profile name (required for show, create, edit, delete) --container= Floci container name (default: floci-oci) --endpoint= Floci server endpoint URL (default: http://localhost:4599) -h, --help Show this help message and exit. --image= create: Docker image for this instance + --json Shorthand for --output json --namespace= create: Docker resource namespace for the containers this instance launches (default: derived from --container) --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --persist= create: host directory that keeps this instance's state diff --git a/docs/help/floci-oci-config-show.txt b/docs/help/floci-oci-config-show.txt index 50aa49a..a353675 100644 --- a/docs/help/floci-oci-config-show.txt +++ b/docs/help/floci-oci-config-show.txt @@ -1,10 +1,13 @@ -Usage: floci oci config show [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci oci config show [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Show the active Floci OCI configuration --container= Floci container name (default: floci-oci) --endpoint= Floci server endpoint URL (default: http://localhost:4599) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-oci-config-validate.txt b/docs/help/floci-oci-config-validate.txt index 05e3a08..a0f60aa 100644 --- a/docs/help/floci-oci-config-validate.txt +++ b/docs/help/floci-oci-config-validate.txt @@ -1,11 +1,15 @@ -Usage: floci oci config validate [-hqvV] [--no-color] [--container=] [--endpoint=] - [-f=] [-o=text|json|yaml] [--profile=] +Usage: floci oci config validate [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-f=] [-o=text|json|yaml] + [--profile=] Validate a docker-compose.yml file for Floci OCI compatibility --container= Floci container name (default: floci-oci) --endpoint= Floci server endpoint URL (default: http://localhost:4599) -f, --file= Path to docker-compose file -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-oci-doctor.txt b/docs/help/floci-oci-doctor.txt index ca026f9..b2a71d8 100644 --- a/docs/help/floci-oci-doctor.txt +++ b/docs/help/floci-oci-doctor.txt @@ -1,11 +1,15 @@ -Usage: floci oci doctor [-hqvV] [--no-color] [--check=] [--container=] - [--endpoint=] [-o=text|json|yaml] [--profile=] +Usage: floci oci doctor [-hqvV] [--json] [--no-color] [--no-emoji] [--check=] + [--container=] [--endpoint=] [-o=text|json|yaml] + [--profile=] Run environment diagnostics for Floci OCI --check= Run only a specific check by name --container= Floci container name (default: floci-oci) --endpoint= Floci server endpoint URL (default: http://localhost:4599) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-oci-env.txt b/docs/help/floci-oci-env.txt index 160bbc2..d44f382 100644 --- a/docs/help/floci-oci-env.txt +++ b/docs/help/floci-oci-env.txt @@ -1,10 +1,13 @@ -Usage: floci oci env [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] [--shell=] +Usage: floci oci env [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] [--shell=] Print OCI environment variables to connect to Floci OCI --container= Floci container name (default: floci-oci) --endpoint= Floci server endpoint URL (default: http://localhost:4599) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-oci-logs.txt b/docs/help/floci-oci-logs.txt index 10b8a19..04e1119 100644 --- a/docs/help/floci-oci-logs.txt +++ b/docs/help/floci-oci-logs.txt @@ -1,12 +1,15 @@ -Usage: floci oci logs [-fhqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] [--service=] +Usage: floci oci logs [-fhqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] [--service=] [--since=] [--tail=] Fetch logs from the Floci OCI container --container= Floci container name (default: floci-oci) --endpoint= Floci server endpoint URL (default: http://localhost:4599) -f, --follow Follow log output -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-oci-reset.txt b/docs/help/floci-oci-reset.txt index c4df76b..5578b2e 100644 --- a/docs/help/floci-oci-reset.txt +++ b/docs/help/floci-oci-reset.txt @@ -1,10 +1,13 @@ -Usage: floci oci reset [-hqvVy] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci oci reset [-hqvVy] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Delete every resource in the running Floci OCI instance, keeping it running --container= Floci container name (default: floci-oci) --endpoint= Floci server endpoint URL (default: http://localhost:4599) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-oci-restart.txt b/docs/help/floci-oci-restart.txt index 8d514c2..cd6ca54 100644 --- a/docs/help/floci-oci-restart.txt +++ b/docs/help/floci-oci-restart.txt @@ -1,10 +1,13 @@ -Usage: floci oci restart [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci oci restart [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Stop and restart the Floci OCI container --container= Floci container name (default: floci-oci) --endpoint= Floci server endpoint URL (default: http://localhost:4599) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-oci-services.txt b/docs/help/floci-oci-services.txt index 68f199b..f174fcd 100644 --- a/docs/help/floci-oci-services.txt +++ b/docs/help/floci-oci-services.txt @@ -1,10 +1,13 @@ -Usage: floci oci services [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci oci services [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] List services available in the running Floci OCI instance --container= Floci container name (default: floci-oci) --endpoint= Floci server endpoint URL (default: http://localhost:4599) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-oci-setup.txt b/docs/help/floci-oci-setup.txt index 92b3b98..e68eb01 100644 --- a/docs/help/floci-oci-setup.txt +++ b/docs/help/floci-oci-setup.txt @@ -1,10 +1,14 @@ -Usage: floci oci setup [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] [--profile-name=] +Usage: floci oci setup [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] + [--profile-name=] Create a local OCI CLI profile (API key + ~/.oci/config) for the emulator --container= Floci container name (default: floci-oci) --endpoint= Floci server endpoint URL (default: http://localhost:4599) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-oci-snapshot-delete.txt b/docs/help/floci-oci-snapshot-delete.txt index e97a054..0ab58ac 100644 --- a/docs/help/floci-oci-snapshot-delete.txt +++ b/docs/help/floci-oci-snapshot-delete.txt @@ -1,11 +1,14 @@ -Usage: floci oci snapshot delete [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci oci snapshot delete [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Delete a Floci OCI snapshot Snapshot name --container= Floci container name (default: floci-oci) --endpoint= Floci server endpoint URL (default: http://localhost:4599) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-oci-snapshot-export.txt b/docs/help/floci-oci-snapshot-export.txt index a7c6074..9bbdf8c 100644 --- a/docs/help/floci-oci-snapshot-export.txt +++ b/docs/help/floci-oci-snapshot-export.txt @@ -1,12 +1,16 @@ -Usage: floci oci snapshot export [-hqvV] [--no-color] [--container=] [--endpoint=] - -f= [-o=text|json|yaml] [--profile=] +Usage: floci oci snapshot export [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] -f= [-o=text|json|yaml] + [--profile=] Export a Floci OCI snapshot to a tarball file Snapshot name --container= Floci container name (default: floci-oci) --endpoint= Floci server endpoint URL (default: http://localhost:4599) -f, --file= Destination file path -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-oci-snapshot-import.txt b/docs/help/floci-oci-snapshot-import.txt index 5ea597f..6cbb3e7 100644 --- a/docs/help/floci-oci-snapshot-import.txt +++ b/docs/help/floci-oci-snapshot-import.txt @@ -1,12 +1,16 @@ -Usage: floci oci snapshot import [-hqvV] [--no-color] [--container=] [--endpoint=] - -f= [--name=] [-o=text|json|yaml] [--profile=] +Usage: floci oci snapshot import [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] -f= [--name=] [-o=text|json|yaml] + [--profile=] Import a Floci OCI snapshot from a tarball file --container= Floci container name (default: floci-oci) --endpoint= Floci server endpoint URL (default: http://localhost:4599) -f, --file= Source tarball path -h, --help Show this help message and exit. + --json Shorthand for --output json --name= Name for the imported snapshot --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-oci-snapshot-list.txt b/docs/help/floci-oci-snapshot-list.txt index cccbc1e..f905ac5 100644 --- a/docs/help/floci-oci-snapshot-list.txt +++ b/docs/help/floci-oci-snapshot-list.txt @@ -1,10 +1,13 @@ -Usage: floci oci snapshot list [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci oci snapshot list [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] List available Floci OCI snapshots --container= Floci container name (default: floci-oci) --endpoint= Floci server endpoint URL (default: http://localhost:4599) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-oci-snapshot-load.txt b/docs/help/floci-oci-snapshot-load.txt index a118368..132882f 100644 --- a/docs/help/floci-oci-snapshot-load.txt +++ b/docs/help/floci-oci-snapshot-load.txt @@ -1,11 +1,14 @@ -Usage: floci oci snapshot load [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci oci snapshot load [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Load a Floci OCI snapshot Snapshot name --container= Floci container name (default: floci-oci) --endpoint= Floci server endpoint URL (default: http://localhost:4599) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-oci-snapshot-save.txt b/docs/help/floci-oci-snapshot-save.txt index f806e67..446fa3e 100644 --- a/docs/help/floci-oci-snapshot-save.txt +++ b/docs/help/floci-oci-snapshot-save.txt @@ -1,12 +1,16 @@ -Usage: floci oci snapshot save [-hqvV] [--no-color] [--container=] [--endpoint=] - [-m=] [-o=text|json|yaml] [--profile=] +Usage: floci oci snapshot save [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-m=] [-o=text|json|yaml] + [--profile=] Save the current Floci OCI state as a named snapshot Snapshot name --container= Floci container name (default: floci-oci) --endpoint= Floci server endpoint URL (default: http://localhost:4599) -h, --help Show this help message and exit. + --json Shorthand for --output json -m, --message= Optional description --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-oci-start.txt b/docs/help/floci-oci-start.txt index fe6ace4..45ce9c5 100644 --- a/docs/help/floci-oci-start.txt +++ b/docs/help/floci-oci-start.txt @@ -1,16 +1,19 @@ -Usage: floci oci start [-hqvV] [--detach] [--no-color] [--container=] [--endpoint=] - [--image=] [--namespace=] [-o=text|json|yaml] [--persist=] - [--port=] [--profile=] [--pull=always|missing|never] - [--services=] +Usage: floci oci start [-hqvV] [--detach] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [--image=] [--namespace=] [-o=text|json|yaml] + [--persist=] [--port=] [--profile=] + [--pull=always|missing|never] [--services=] Start the Floci OCI emulator container --container= Floci container name (default: floci-oci) --detach Return immediately without waiting for readiness --endpoint= Floci server endpoint URL (default: http://localhost:4599) -h, --help Show this help message and exit. --image= Image reference to use (default: floci/floci-oci:latest) + --json Shorthand for --output json --namespace= Docker resource namespace for the containers this instance launches (default: derived from --container; none for the default container) --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --persist= Host directory for persistent state diff --git a/docs/help/floci-oci-status.txt b/docs/help/floci-oci-status.txt index 662971f..725dcff 100644 --- a/docs/help/floci-oci-status.txt +++ b/docs/help/floci-oci-status.txt @@ -1,10 +1,13 @@ -Usage: floci oci status [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci oci status [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Show Floci OCI container and server status --container= Floci container name (default: floci-oci) --endpoint= Floci server endpoint URL (default: http://localhost:4599) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-oci-stop.txt b/docs/help/floci-oci-stop.txt index e44fbfd..ff0bd28 100644 --- a/docs/help/floci-oci-stop.txt +++ b/docs/help/floci-oci-stop.txt @@ -1,10 +1,14 @@ -Usage: floci oci stop [-hqrvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] [--timeout=] +Usage: floci oci stop [-hqrvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] + [--timeout=] Stop the Floci OCI container --container= Floci container name (default: floci-oci) --endpoint= Floci server endpoint URL (default: http://localhost:4599) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-oci-version.txt b/docs/help/floci-oci-version.txt index ba3140b..87c7918 100644 --- a/docs/help/floci-oci-version.txt +++ b/docs/help/floci-oci-version.txt @@ -1,10 +1,13 @@ -Usage: floci oci version [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci oci version [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Show CLI version, connected Floci OCI server version, and image digest --container= Floci container name (default: floci-oci) --endpoint= Floci server endpoint URL (default: http://localhost:4599) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-oci-wait.txt b/docs/help/floci-oci-wait.txt index 3c4c9bc..551de79 100644 --- a/docs/help/floci-oci-wait.txt +++ b/docs/help/floci-oci-wait.txt @@ -1,11 +1,14 @@ -Usage: floci oci wait [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] [--service=] +Usage: floci oci wait [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] [--service=] [--timeout=] Wait until Floci OCI is ready to accept requests --container= Floci container name (default: floci-oci) --endpoint= Floci server endpoint URL (default: http://localhost:4599) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-reset.txt b/docs/help/floci-reset.txt index e139ed7..1dfec6a 100644 --- a/docs/help/floci-reset.txt +++ b/docs/help/floci-reset.txt @@ -1,10 +1,13 @@ -Usage: floci reset [-hqvVy] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci reset [-hqvVy] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Delete every resource in the running Floci AWS instance, keeping it running --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-restart.txt b/docs/help/floci-restart.txt index 9e825f3..97aa293 100644 --- a/docs/help/floci-restart.txt +++ b/docs/help/floci-restart.txt @@ -1,10 +1,13 @@ -Usage: floci restart [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci restart [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Stop and restart the Floci AWS container --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-services.txt b/docs/help/floci-services.txt index 23e551e..21cfcdc 100644 --- a/docs/help/floci-services.txt +++ b/docs/help/floci-services.txt @@ -1,10 +1,13 @@ -Usage: floci services [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci services [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] List services available in the running Floci AWS instance --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-snapshot-delete.txt b/docs/help/floci-snapshot-delete.txt index 13432df..4e4610b 100644 --- a/docs/help/floci-snapshot-delete.txt +++ b/docs/help/floci-snapshot-delete.txt @@ -1,11 +1,14 @@ -Usage: floci snapshot delete [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci snapshot delete [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Delete a Floci AWS snapshot Snapshot name --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-snapshot-export.txt b/docs/help/floci-snapshot-export.txt index 3d82013..fdf8964 100644 --- a/docs/help/floci-snapshot-export.txt +++ b/docs/help/floci-snapshot-export.txt @@ -1,12 +1,16 @@ -Usage: floci snapshot export [-hqvV] [--no-color] [--container=] [--endpoint=] -f= - [-o=text|json|yaml] [--profile=] +Usage: floci snapshot export [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] -f= [-o=text|json|yaml] [--profile=] + Export a Floci AWS snapshot to a tarball file Snapshot name --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -f, --file= Destination file path -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-snapshot-import.txt b/docs/help/floci-snapshot-import.txt index d734a7c..7de027b 100644 --- a/docs/help/floci-snapshot-import.txt +++ b/docs/help/floci-snapshot-import.txt @@ -1,12 +1,16 @@ -Usage: floci snapshot import [-hqvV] [--no-color] [--container=] [--endpoint=] -f= - [--name=] [-o=text|json|yaml] [--profile=] +Usage: floci snapshot import [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] -f= [--name=] [-o=text|json|yaml] + [--profile=] Import a Floci AWS snapshot from a tarball file --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -f, --file= Source tarball path -h, --help Show this help message and exit. + --json Shorthand for --output json --name= Name for the imported snapshot --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-snapshot-list.txt b/docs/help/floci-snapshot-list.txt index ca4f995..75efcbf 100644 --- a/docs/help/floci-snapshot-list.txt +++ b/docs/help/floci-snapshot-list.txt @@ -1,10 +1,13 @@ -Usage: floci snapshot list [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci snapshot list [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] List available Floci AWS snapshots --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-snapshot-load.txt b/docs/help/floci-snapshot-load.txt index c31b144..7520285 100644 --- a/docs/help/floci-snapshot-load.txt +++ b/docs/help/floci-snapshot-load.txt @@ -1,11 +1,14 @@ -Usage: floci snapshot load [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci snapshot load [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Load a Floci AWS snapshot Snapshot name --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-snapshot-save.txt b/docs/help/floci-snapshot-save.txt index 7718245..eb8bbfc 100644 --- a/docs/help/floci-snapshot-save.txt +++ b/docs/help/floci-snapshot-save.txt @@ -1,12 +1,16 @@ -Usage: floci snapshot save [-hqvV] [--no-color] [--container=] [--endpoint=] [-m=] - [-o=text|json|yaml] [--profile=] +Usage: floci snapshot save [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-m=] [-o=text|json|yaml] [--profile=] + Save the current Floci AWS state as a named snapshot Snapshot name --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json -m, --message= Optional description --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-start.txt b/docs/help/floci-start.txt index 9cb6f4f..dbcb69d 100644 --- a/docs/help/floci-start.txt +++ b/docs/help/floci-start.txt @@ -1,16 +1,19 @@ -Usage: floci start [-hqvV] [--detach] [--no-color] [--container=] [--endpoint=] - [--image=] [--namespace=] [-o=text|json|yaml] [--persist=] - [--port=] [--profile=] [--pull=always|missing|never] - [--services=] +Usage: floci start [-hqvV] [--detach] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [--image=] [--namespace=] [-o=text|json|yaml] + [--persist=] [--port=] [--profile=] + [--pull=always|missing|never] [--services=] Start the Floci AWS emulator container --container= Floci container name (default: floci) --detach Return immediately without waiting for readiness --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. --image= Image reference to use (default: floci/floci:latest) + --json Shorthand for --output json --namespace= Docker resource namespace for the containers this instance launches (default: derived from --container; none for the default container) --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --persist= Host directory for persistent state diff --git a/docs/help/floci-status.txt b/docs/help/floci-status.txt index b80a655..7e25e33 100644 --- a/docs/help/floci-status.txt +++ b/docs/help/floci-status.txt @@ -1,10 +1,13 @@ -Usage: floci status [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci status [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Show Floci AWS container and server status --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-stop.txt b/docs/help/floci-stop.txt index 23197b9..6a87cfe 100644 --- a/docs/help/floci-stop.txt +++ b/docs/help/floci-stop.txt @@ -1,10 +1,13 @@ -Usage: floci stop [-hqrvV] [--no-color] [--container=] [--endpoint=] [-o=text|json|yaml] - [--profile=] [--timeout=] +Usage: floci stop [-hqrvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] [--timeout=] Stop the Floci AWS container --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-version.txt b/docs/help/floci-version.txt index 35d7247..fb1eeec 100644 --- a/docs/help/floci-version.txt +++ b/docs/help/floci-version.txt @@ -1,10 +1,13 @@ -Usage: floci version [-hqvV] [--no-color] [--container=] [--endpoint=] - [-o=text|json|yaml] [--profile=] +Usage: floci version [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] Show CLI version, connected Floci AWS server version, and image digest --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/docs/help/floci-wait.txt b/docs/help/floci-wait.txt index 82c3484..5d86aa2 100644 --- a/docs/help/floci-wait.txt +++ b/docs/help/floci-wait.txt @@ -1,10 +1,14 @@ -Usage: floci wait [-hqvV] [--no-color] [--container=] [--endpoint=] [-o=text|json|yaml] - [--profile=] [--service=] [--timeout=] +Usage: floci wait [-hqvV] [--json] [--no-color] [--no-emoji] [--container=] + [--endpoint=] [-o=text|json|yaml] [--profile=] [--service=] + [--timeout=] Wait until Floci AWS is ready to accept requests --container= Floci container name (default: floci) --endpoint= Floci server endpoint URL (default: http://localhost:4566) -h, --help Show this help message and exit. + --json Shorthand for --output json --no-color Disable ANSI colors + --no-emoji Plain ASCII marks instead of Unicode ones (the default when output is + piped) -o, --output=text|json|yaml Output format: text, json, yaml --profile= Config profile from ~/.floci/profiles/ diff --git a/src/main/java/io/floci/cli/FlociCli.java b/src/main/java/io/floci/cli/FlociCli.java index 39e98b2..dee05f5 100644 --- a/src/main/java/io/floci/cli/FlociCli.java +++ b/src/main/java/io/floci/cli/FlociCli.java @@ -12,6 +12,7 @@ import io.floci.cli.config.ProfileDefaultValueProvider; import io.floci.cli.config.ProfileNotFoundException; import io.floci.cli.config.ProfileStore; import io.floci.cli.output.Ansi; +import io.floci.cli.output.Glyphs; import io.floci.cli.update.UpdateNotifier; import picocli.CommandLine; import picocli.CommandLine.*; @@ -80,6 +81,11 @@ public class FlociCli implements Runnable { if (colorDisabled(args, System.getenv("NO_COLOR") != null, System.console() != null)) { Ansi.disable(); } + // Decided here too, not only when a command builds its printer: the update notice below + // is printed before any command runs. + if (plainGlyphs(args, System.getenv("NO_COLOR") != null, System.console() != null)) { + Glyphs.plain(); + } // If no explicit product subcommand, route bare commands to the configured default. // "floci az start" and "floci aws start" always win; only bare "floci start" is affected. @@ -103,7 +109,7 @@ public class FlociCli implements Runnable { if (notify) { UpdateNotifier.pendingNotice(CliVersion.CLI_VERSION).ifPresent(latest -> System.err.println(Ansi.yellow("A new release of floci is available: " - + CliVersion.CLI_VERSION + " → " + latest + "\n" + + CliVersion.CLI_VERSION + " " + Glyphs.arrow() + " " + latest + "\n" + "Run 'floci update' to install it") + "\n")); UpdateNotifier.refreshInBackground(); } @@ -154,6 +160,13 @@ public class FlociCli implements Runnable { * arguments here as well as by {@code GlobalOptions.printer()}: a parse error is printed by the * exception handlers before any command, and so any printer, exists. */ + /** Whether marks are plain ASCII for this invocation, read from the raw arguments like {@link #colorDisabled}. */ + public static boolean plainGlyphs(String[] args, boolean noColorEnv, boolean interactive) { + boolean flag = Arrays.stream(args) + .anyMatch(a -> a.equals("--no-emoji") || a.equalsIgnoreCase("--no-emoji=true")); + return GlobalOptions.plainGlyphs(flag, interactive, noColorEnv); + } + public static boolean colorDisabled(String[] args, boolean noColorEnv, boolean interactive) { return noColorEnv || !interactive || Arrays.stream(args) .anyMatch(a -> a.equals("--no-color") || a.equalsIgnoreCase("--no-color=true")); diff --git a/src/main/java/io/floci/cli/GlobalOptions.java b/src/main/java/io/floci/cli/GlobalOptions.java index a2f895b..50826a4 100644 --- a/src/main/java/io/floci/cli/GlobalOptions.java +++ b/src/main/java/io/floci/cli/GlobalOptions.java @@ -2,6 +2,7 @@ package io.floci.cli; import io.floci.cli.docker.DockerClient; import io.floci.cli.output.Ansi; +import io.floci.cli.output.Glyphs; import io.floci.cli.output.OutputFormat; import io.floci.cli.output.Printer; import picocli.CommandLine.Model.CommandSpec; @@ -61,6 +62,9 @@ public class GlobalOptions { paramLabel = "text|json|yaml") public OutputFormat output; + @Option(names = {"--json"}, description = "Shorthand for --output json") + public boolean json; + @Option(names = {"--quiet", "-q"}, description = "Suppress non-error output") public boolean quiet; @@ -70,6 +74,9 @@ public class GlobalOptions { @Option(names = {"--no-color"}, description = "Disable ANSI colors") public boolean noColor; + @Option(names = {"--no-emoji"}, description = "Plain ASCII marks instead of Unicode ones (the default when output is piped)") + public boolean noEmoji; + public GlobalOptions() { this(ProductProfile.AWS); } @@ -131,7 +138,23 @@ public class GlobalOptions { if (verbose) { System.setProperty(VERBOSE_PROPERTY, "true"); } - return new Printer(System.out, System.err, output, quiet); + if (plainGlyphs(noEmoji, isStdoutTty(), System.getenv("NO_COLOR") != null)) { + Glyphs.plain(); + } + return new Printer(System.out, System.err, format(), quiet); + } + + /** The output format in effect: {@code --json} is {@code --output json} and wins over it. */ + public OutputFormat format() { + return json ? OutputFormat.json : output; + } + + /** + * Whether marks are printed as plain ASCII: on request, when nobody is looking at a terminal + * (a pipe, a file, CI logs), or when NO_COLOR asks for undecorated output. + */ + public static boolean plainGlyphs(boolean noEmoji, boolean terminal, boolean noColorEnv) { + return noEmoji || !terminal || noColorEnv; } // Inspects the container and derives the endpoint from its host port mapping. diff --git a/src/main/java/io/floci/cli/ServerCompatibility.java b/src/main/java/io/floci/cli/ServerCompatibility.java new file mode 100644 index 0000000..e2e3d8d --- /dev/null +++ b/src/main/java/io/floci/cli/ServerCompatibility.java @@ -0,0 +1,40 @@ +package io.floci.cli; + +import io.floci.cli.doctor.checks.ImageVersionCheck; +import io.floci.cli.update.Version; + +import java.util.Optional; + +/** Whether a running server is new enough for this CLI. */ +public final class ServerCompatibility { + + private ServerCompatibility() {} + + /** + * What to tell the user when {@code product}'s server reports {@code serverVersion}, or empty + * when there is nothing to say. Only the AWS emulator has a minimum: the others are versioned + * on their own lines (0.x), where the same number would flag every release. A version that + * does not read as one ("unknown", a development build) is not judged. + * + * @param instanceSelector the flags that select the instance the version came from + * ({@link GlobalOptions#instanceSelector()}), so the hint acts on that + * instance and not on the default one + */ + public static Optional warning(ProductProfile product, String serverVersion, String instanceSelector) { + if (!"aws".equals(product.name()) || !Version.isValid(serverVersion) + || ImageVersionCheck.meetsMinimum(serverVersion, ImageVersionCheck.MIN_VERSION)) { + return Optional.empty(); + } + // restart, not stop and start: it brings the instance back with the port, data directory + // and services it has now. It also keeps the image reference, so an instance pinned to an + // old tag needs that changed first; the hint says where. + String prefix = product.commandPrefix(); + return Optional.of(product.displayName() + " server " + serverVersion + " is older than " + + ImageVersionCheck.MIN_VERSION + ", the oldest version this CLI supports; some commands may not work." + + "\nPull a newer image ('docker pull " + product.defaultImageRef() + "'), then run '" + + prefix + " restart" + instanceSelector + "'." + + "\nIf the instance pins an older tag, restart keeps it: change 'image' in its profile first, or run '" + + prefix + " stop --remove" + instanceSelector + "' and start it again with its usual flags plus" + + " '--image " + product.defaultImageRef() + "'."); + } +} diff --git a/src/main/java/io/floci/cli/commands/CompletionCommand.java b/src/main/java/io/floci/cli/commands/CompletionCommand.java index b22f662..a70de55 100644 --- a/src/main/java/io/floci/cli/commands/CompletionCommand.java +++ b/src/main/java/io/floci/cli/commands/CompletionCommand.java @@ -21,7 +21,9 @@ public class CompletionCommand implements Callable { @Spec Model.CommandSpec spec; - @Parameters(index = "0", description = "Shell type: bash, zsh, fish, powershell", paramLabel = "bash|zsh|fish|powershell") + // Only the shells a script is generated for: picocli writes bash completion, which zsh loads + // through bashcompinit. Listing fish and powershell here promised scripts that do not exist. + @Parameters(index = "0", description = "Shell type: bash or zsh", paramLabel = "bash|zsh") String shell; @Override @@ -36,13 +38,13 @@ public class CompletionCommand implements Callable { case "bash" -> AutoComplete.bash("floci", root); case "zsh" -> AutoComplete.bash("floci", root); // zsh is bash-compatible; picocli bash script works for zsh too default -> { - printer.error("Shell '" + shell + "' not supported. Supported: bash, zsh\n" + - "For fish and powershell, track https://github.com/floci-io/floci-cli/issues"); + printer.error("Shell '" + shell + "' is not supported.\nUse bash or zsh."); yield null; } }; - if (script == null) return 1; + // A value the command cannot accept, like any other bad argument. + if (script == null) return ExitCode.USAGE; System.out.print(script); return 0; } diff --git a/src/main/java/io/floci/cli/commands/DoctorCommand.java b/src/main/java/io/floci/cli/commands/DoctorCommand.java index 1e92fca..ebb6014 100644 --- a/src/main/java/io/floci/cli/commands/DoctorCommand.java +++ b/src/main/java/io/floci/cli/commands/DoctorCommand.java @@ -21,6 +21,7 @@ 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.Glyphs; import io.floci.cli.output.OutputFormat; import io.floci.cli.output.Printer; import picocli.CommandLine.*; @@ -226,9 +227,9 @@ public class DoctorCommand implements Callable { public static void printResult(Printer printer, CheckResult r) { String icon = switch (r.status()) { - case ok -> Ansi.green("✓"); - case warn -> Ansi.yellow("⚠"); - case fail -> Ansi.red("✗"); + case ok -> Ansi.green(Glyphs.ok()); + case warn -> Ansi.yellow(Glyphs.warn()); + case fail -> Ansi.red(Glyphs.fail()); }; String namePadded = String.format("%-26s", r.name()); printer.println(" " + icon + " " + namePadded + " " + r.message()); diff --git a/src/main/java/io/floci/cli/commands/LogsCommand.java b/src/main/java/io/floci/cli/commands/LogsCommand.java index b2ad0f2..af0f752 100644 --- a/src/main/java/io/floci/cli/commands/LogsCommand.java +++ b/src/main/java/io/floci/cli/commands/LogsCommand.java @@ -4,6 +4,7 @@ import io.floci.cli.GlobalOptions; import io.floci.cli.ProductProfile; 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.*; @@ -58,6 +59,11 @@ public class LogsCommand implements Callable { return 1; } + if (printer.format() != OutputFormat.text) { + // Logs are the container's own output, line by line; there is no document to build. + printer.warn("logs prints the container's output as plain text; -o " + printer.format() + " is ignored."); + } + if (service != null) { printer.warn("--service filtering is not yet supported. Showing all container logs."); } diff --git a/src/main/java/io/floci/cli/commands/ResetCommand.java b/src/main/java/io/floci/cli/commands/ResetCommand.java index 5018750..d1aec6f 100644 --- a/src/main/java/io/floci/cli/commands/ResetCommand.java +++ b/src/main/java/io/floci/cli/commands/ResetCommand.java @@ -7,6 +7,7 @@ import io.floci.cli.docker.DockerException; import io.floci.cli.http.FlociException; import io.floci.cli.http.FlociHttpClient; import io.floci.cli.output.Ansi; +import io.floci.cli.output.Glyphs; import io.floci.cli.output.OutputFormat; import io.floci.cli.output.Printer; import picocli.CommandLine.*; @@ -166,7 +167,7 @@ public class ResetCommand implements Callable { printer.structured(out); return 0; } - printer.println(Ansi.green("✓") + " " + profile.displayName() + " state reset" + Ansi.gray(" (" + effectiveEndpoint + ")")); + printer.println(Ansi.green(Glyphs.ok()) + " " + profile.displayName() + " state reset" + Ansi.gray(" (" + effectiveEndpoint + ")")); return 0; } } diff --git a/src/main/java/io/floci/cli/commands/RestartCommand.java b/src/main/java/io/floci/cli/commands/RestartCommand.java index 85b2e11..a3754e9 100644 --- a/src/main/java/io/floci/cli/commands/RestartCommand.java +++ b/src/main/java/io/floci/cli/commands/RestartCommand.java @@ -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 { 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 { * 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; diff --git a/src/main/java/io/floci/cli/commands/ServicesCommand.java b/src/main/java/io/floci/cli/commands/ServicesCommand.java index 06f6527..6d28cdc 100644 --- a/src/main/java/io/floci/cli/commands/ServicesCommand.java +++ b/src/main/java/io/floci/cli/commands/ServicesCommand.java @@ -5,6 +5,7 @@ import io.floci.cli.ProductProfile; import io.floci.cli.docker.DockerClient; import io.floci.cli.http.FlociHttpClient; import io.floci.cli.output.Ansi; +import io.floci.cli.output.Glyphs; import io.floci.cli.output.OutputFormat; import io.floci.cli.output.Printer; import picocli.CommandLine.*; @@ -61,7 +62,7 @@ public class ServicesCommand implements Callable { printer.println(Ansi.bold(profile.displayName() + " Services") + " " + Ansi.gray("(" + services.size() + " enabled)")); printer.println(""); for (String svc : services) { - printer.println(" " + Ansi.green("✓") + " " + svc); + printer.println(" " + Ansi.green(Glyphs.ok()) + " " + svc); } if (services.isEmpty()) { printer.println(" " + Ansi.gray("(no services reported)")); diff --git a/src/main/java/io/floci/cli/commands/StartCommand.java b/src/main/java/io/floci/cli/commands/StartCommand.java index 7ab7887..ce907ab 100644 --- a/src/main/java/io/floci/cli/commands/StartCommand.java +++ b/src/main/java/io/floci/cli/commands/StartCommand.java @@ -10,6 +10,7 @@ import io.floci.cli.doctor.CheckStatus; import io.floci.cli.doctor.checks.DockerSocketCheck; 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.*; @@ -19,10 +20,13 @@ import java.nio.file.Files; import java.nio.file.InvalidPathException; import java.nio.file.Path; import java.util.ArrayList; +import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; +import java.util.Map; import java.util.TreeMap; import java.util.concurrent.Callable; +import java.util.function.Consumer; import java.util.regex.Pattern; @Command( @@ -295,6 +299,10 @@ public class StartCommand implements Callable { @Override public Integer call() { Printer printer = global.printer(); + // Structured output is one document on stdout: the progress lines a person reads are + // left out, and docker's own pull progress goes to stderr. + boolean structured = printer.format() != OutputFormat.text; + Consumer progress = structured ? line -> { } : printer::println; String invalid = validationError(); if (invalid != null) { @@ -323,7 +331,7 @@ public class StartCommand implements Callable { return 1; } // Remove stopped container so we can start fresh - printer.println(Ansi.gray("Removing stopped container '" + global.container + "'...")); + progress.accept(Ansi.gray("Removing stopped container '" + global.container + "'...")); docker.removeContainer(global.container); } } catch (DockerException e) { @@ -350,8 +358,12 @@ public class StartCommand implements Callable { // Pull image if needed try { - printer.println(Ansi.gray("Checking image " + image + " (policy: " + pull + ")...")); - docker.pull(image, pull); + progress.accept(Ansi.gray("Checking image " + image + " (policy: " + pull + ")...")); + if (structured) { + docker.pull(image, pull, System.err); + } else { + docker.pull(image, pull); + } } catch (DockerException e) { printer.error("Failed to pull image: " + e.getMessage() + "\nRun '" + profile.commandPrefix() + " start --pull never' to skip pulling."); return 1; @@ -359,32 +371,66 @@ public class StartCommand implements Callable { List args = dockerRunArgs(DockerClient.dockerSocketRunArgs(), daemon); + String id; try { - printer.println("Starting " + Ansi.gold(profile.displayName()) + " container..."); - String id = docker.startContainer(args); - printer.println(Ansi.green("Container started") + " (" + id.substring(0, Math.min(12, id.length())) + ")"); + progress.accept("Starting " + Ansi.gold(profile.displayName()) + " container..."); + id = docker.startContainer(args); + progress.accept(Ansi.green("Container started") + " (" + id.substring(0, Math.min(12, id.length())) + ")"); } catch (DockerException e) { printer.error("Failed to start container: " + e.getMessage(), "Run '" + profile.commandPrefix() + " doctor' to check Docker, the image and the port."); return 1; } + // The endpoint of the port actually bound, keeping whatever host the endpoint already + // names — a profile or --endpoint may well point somewhere else. + String endpoint = withPort(global.endpoint, port); + if (detach) { - printer.println(Ansi.gray("Detached. Run '" + profile.commandPrefix() + " wait' to poll for readiness.")); + progress.accept(Ansi.gray("Detached. Run '" + profile.commandPrefix() + " wait' to poll for readiness.")); + if (structured) printer.structured(result(id, endpoint, null)); return 0; } - // Point the readiness poll at the port actually bound, keeping whatever host the - // endpoint already names — a profile or --endpoint may well point somewhere else. - global.endpoint = withPort(global.endpoint, port); + global.endpoint = endpoint; // Wait for readiness - printer.println(Ansi.gray("Waiting for " + profile.displayName() + " to be ready...")); + progress.accept(Ansi.gray("Waiting for " + profile.displayName() + " to be ready...")); WaitCommand wait = new WaitCommand(profile); wait.global = global; - wait.knownEndpoint = global.endpoint; - wait.timeout = "30s"; - return wait.call(); + wait.knownEndpoint = endpoint; + wait.timeout = readinessTimeout(); + wait.embedded = true; + int exit = wait.call(); + if (structured) printer.structured(result(id, endpoint, exit == 0)); + return exit; + } + + /** How long start waits for the emulator to answer. A seam: tests do not wait half a minute. */ + protected String readinessTimeout() { + return "30s"; + } + + // What -o json/yaml reports for a start: 'ready' is left out when --detach did not wait for it. + private Map result(String id, String endpoint, Boolean ready) { + Map result = new LinkedHashMap<>(); + result.put("container", global.container); + result.put("id", id); + result.put("image", image); + result.put("endpoint", endpoint); + result.put("state", stateNow()); + if (ready != null) result.put("ready", ready); + return result; + } + + // Read back, not assumed: a container that crashed while start waited for it has exited, and + // a script must not be told it is running. "unknown" when docker cannot say. + private String stateNow() { + try { + return docker.inspectContainer(global.container).map(DockerClient.ContainerInfo::state).orElse("removed"); + } catch (DockerException e) { + return "unknown"; + } } /** diff --git a/src/main/java/io/floci/cli/commands/StatusCommand.java b/src/main/java/io/floci/cli/commands/StatusCommand.java index ba901c8..34b24cd 100644 --- a/src/main/java/io/floci/cli/commands/StatusCommand.java +++ b/src/main/java/io/floci/cli/commands/StatusCommand.java @@ -2,6 +2,7 @@ package io.floci.cli.commands; import io.floci.cli.GlobalOptions; import io.floci.cli.ProductProfile; +import io.floci.cli.ServerCompatibility; import io.floci.cli.docker.DockerClient; import io.floci.cli.docker.DockerException; import io.floci.cli.http.FlociHttpClient; @@ -32,14 +33,21 @@ public class StatusCommand implements Callable { } protected StatusCommand(ProductProfile profile) { + this(profile, new DockerClient()); + } + + /** Test seam: {@code docker} answers the container lookup. */ + public StatusCommand(ProductProfile profile, DockerClient docker) { this.profile = profile; this.global = new GlobalOptions(profile); + this.docker = docker; } + private final DockerClient docker; + @Override public Integer call() { Printer printer = global.printer(); - DockerClient docker = new DockerClient(); // Gather container info String containerState = "not found"; @@ -69,6 +77,8 @@ public class StatusCommand implements Callable { serverEdition = health.edition(); reachable = true; } catch (Exception ignored) {} + // On stderr, so structured output stays one document. + ServerCompatibility.warning(profile, serverVersion, global.instanceSelector()).ifPresent(printer::warn); Map data = new LinkedHashMap<>(); data.put("container", global.container); @@ -80,9 +90,10 @@ public class StatusCommand implements Callable { data.put("version", serverVersion); data.put("edition", serverEdition); + int exit = exitCode(containerState, reachable); if (printer.format() != OutputFormat.text) { printer.structured(data); - return 0; + return exit; } printer.println(Ansi.bold(profile.displayName() + " Status")); @@ -107,7 +118,20 @@ public class StatusCommand implements Callable { printer.println(Ansi.gray("Run '" + profile.commandPrefix() + " start' to launch " + profile.displayName() + ".")); } - return 0; + return exit; + } + + /** + * 0 when the instance is up, 1 when it is not, so a script can ask. Up means the server + * answers and its container, if there is one, is running. An instance with no container here + * (a remote endpoint, a Compose service under another name), or whose container docker could + * not look up, is up when it answers. + */ + public static int exitCode(String containerState, boolean reachable) { + // A lookup that failed ("error: ...") says nothing about the container either way. + boolean containerDown = !"running".equals(containerState) && !"not found".equals(containerState) + && !containerState.startsWith("error:"); + return reachable && !containerDown ? 0 : 1; } } diff --git a/src/main/java/io/floci/cli/commands/StopCommand.java b/src/main/java/io/floci/cli/commands/StopCommand.java index 1af7136..2d75e6e 100644 --- a/src/main/java/io/floci/cli/commands/StopCommand.java +++ b/src/main/java/io/floci/cli/commands/StopCommand.java @@ -5,10 +5,14 @@ import io.floci.cli.ProductProfile; import io.floci.cli.docker.DockerClient; import io.floci.cli.docker.DockerException; 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.concurrent.Callable; +import java.util.function.Consumer; @Command( name = "stop", @@ -27,10 +31,24 @@ public class StopCommand implements Callable { } protected StopCommand(ProductProfile profile) { + this(profile, new DockerClient()); + } + + /** Test seam: {@code docker} answers every docker call this stop makes. */ + public StopCommand(ProductProfile profile, DockerClient docker) { this.profile = profile; this.global = new GlobalOptions(profile); + this.docker = docker; } + private final DockerClient docker; + + /** + * Set by {@code restart}, whose start reports the outcome: this stop then prints no structured + * document of its own, so stdout carries exactly one. + */ + boolean embedded; + @Option(names = {"--remove", "-r"}, description = "Remove the container after stopping") boolean remove; @@ -40,7 +58,8 @@ public class StopCommand implements Callable { @Override public Integer call() { Printer printer = global.printer(); - DockerClient docker = new DockerClient(); + boolean structured = printer.format() != OutputFormat.text; + Consumer progress = structured ? line -> { } : printer::println; try { var info = docker.inspectContainer(global.container); @@ -49,11 +68,12 @@ public class StopCommand implements Callable { return 1; } if (!"running".equals(info.get().state())) { - printer.println(Ansi.yellow("Container '" + global.container + "' is not running (state: " + info.get().state() + ")")); + progress.accept(Ansi.yellow("Container '" + global.container + "' is not running (state: " + info.get().state() + ")")); if (remove) { docker.removeContainer(global.container); - printer.println("Container removed."); + progress.accept("Container removed."); } + report(printer, structured, remove ? "removed" : info.get().state(), false, remove); return 0; } } catch (DockerException e) { @@ -62,24 +82,52 @@ public class StopCommand implements Callable { } try { - printer.println("Stopping " + Ansi.gold(profile.displayName()) + " container '" + global.container + "'..."); + progress.accept("Stopping " + Ansi.gold(profile.displayName()) + " container '" + global.container + "'..."); docker.stopContainer(global.container, timeout); - printer.println(Ansi.green("Stopped.")); + progress.accept(Ansi.green("Stopped.")); } catch (DockerException e) { printer.error("Failed to stop container: " + e.withNextStep(DockerClient.CHECK_DOCKER)); return 1; } - if (remove) { + // What is left of it: a container run with docker's --rm is gone the moment it stops, + // whatever --remove said, so the result is read back rather than assumed. + String state = stateNow(); + boolean gone = state == null; + if (remove && !gone) { try { docker.removeContainer(global.container); - printer.println("Container removed."); + gone = true; } catch (DockerException e) { printer.error("Failed to remove container: " + e.withNextStep(DockerClient.CHECK_DOCKER)); return 1; } } + if (remove) progress.accept("Container removed."); + report(printer, structured, gone ? "removed" : state, true, gone); return 0; } + + // The container's state as docker has it now; null when it no longer exists. A lookup that + // fails after a stop that succeeded is reported as the state the stop leaves behind. + private String stateNow() { + try { + return docker.inspectContainer(global.container).map(DockerClient.ContainerInfo::state).orElse(null); + } catch (DockerException e) { + return "exited"; + } + } + + // What -o json/yaml reports for a stop: the state the container was left in, whether this + // call is what stopped it, and whether it was removed. + private void report(Printer printer, boolean structured, String state, boolean stopped, boolean removed) { + if (!structured || embedded) return; + Map result = new LinkedHashMap<>(); + result.put("container", global.container); + result.put("state", state); + result.put("stopped", stopped); + result.put("removed", removed); + printer.structured(result); + } } diff --git a/src/main/java/io/floci/cli/commands/UpdateCommand.java b/src/main/java/io/floci/cli/commands/UpdateCommand.java index 1f0f2b6..5bf0e73 100644 --- a/src/main/java/io/floci/cli/commands/UpdateCommand.java +++ b/src/main/java/io/floci/cli/commands/UpdateCommand.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import io.floci.cli.CliVersion; import io.floci.cli.output.Ansi; +import io.floci.cli.output.Glyphs; import io.floci.cli.output.OutputFormat; import io.floci.cli.output.Printer; import io.floci.cli.update.ReleaseChannel; @@ -109,11 +110,11 @@ public class UpdateCommand implements Callable { // (0.1.9-rc.1) must not be silently downgraded to the latest stable (0.1.8). // Pinned --version keeps exact equality so deliberate downgrades still work. if (pinned ? target.equals(current) : !Version.isNewer(target, current)) { - printer.println(Ansi.green("✓") + " floci " + current + " is up to date"); + printer.println(Ansi.green(Glyphs.ok()) + " floci " + current + " is up to date"); return 0; } - printer.println("update available: " + current + " → " + Ansi.bold(target)); + printer.println("update available: " + current + " " + Glyphs.arrow() + " " + Ansi.bold(target)); if (check) { printer.println(Ansi.gray(installHint())); // Non-zero so scripts can gate on staleness: floci update --check || floci update @@ -132,13 +133,13 @@ public class UpdateCommand implements Callable { Path fresh = work.resolve(asset); fetchFile(ReleaseChannel.assetUrl(downloadBase, target, asset), fresh); verifyChecksum(fresh, asset, fetchString(ReleaseChannel.assetUrl(downloadBase, target, "sha256sums.txt"))); - printer.println(Ansi.green("✓") + " checksum verified"); + printer.println(Ansi.green(Glyphs.ok()) + " checksum verified"); replaceAtomically(fresh, binary); } finally { deleteRecursively(work); } - printer.println(Ansi.green("✓") + " updated: " + current + " → " + target + printer.println(Ansi.green(Glyphs.ok()) + " updated: " + current + " " + Glyphs.arrow() + " " + target + Ansi.gray(" (" + binary + ")")); return 0; } catch (UpdateException e) { @@ -314,7 +315,7 @@ public class UpdateCommand implements Callable { private String fetchString(String url) throws IOException, InterruptedException { HttpResponse resp = http().send(get(url), HttpResponse.BodyHandlers.ofString()); if (resp.statusCode() != 200) { - throw new IOException("GET " + url + " → HTTP " + resp.statusCode()); + throw new IOException("GET " + url + " " + Glyphs.arrow() + " HTTP " + resp.statusCode()); } if (resp.body().isBlank()) { // GitHub's CDN can intermittently return 200 with an empty body (see install.sh). @@ -326,7 +327,7 @@ public class UpdateCommand implements Callable { private void fetchFile(String url, Path dest) throws IOException, InterruptedException { HttpResponse resp = http().send(get(url), HttpResponse.BodyHandlers.ofFile(dest)); if (resp.statusCode() != 200) { - throw new UpdateException("download failed: " + url + " → HTTP " + resp.statusCode() + throw new UpdateException("download failed: " + url + " " + Glyphs.arrow() + " HTTP " + resp.statusCode() + (resp.statusCode() == 404 ? " (does that release exist?)" : "")); } if (Files.size(dest) == 0) { diff --git a/src/main/java/io/floci/cli/commands/VersionCommand.java b/src/main/java/io/floci/cli/commands/VersionCommand.java index b663e54..b8f4000 100644 --- a/src/main/java/io/floci/cli/commands/VersionCommand.java +++ b/src/main/java/io/floci/cli/commands/VersionCommand.java @@ -3,6 +3,7 @@ package io.floci.cli.commands; import io.floci.cli.CliVersion; import io.floci.cli.GlobalOptions; import io.floci.cli.ProductProfile; +import io.floci.cli.ServerCompatibility; import io.floci.cli.http.FlociHttpClient; import io.floci.cli.output.Ansi; import io.floci.cli.output.OutputFormat; @@ -52,6 +53,8 @@ public class VersionCommand implements Callable { serverVersion = info.version(); serverEdition = info.edition(); } catch (Exception ignored) {} + // On stderr, so structured output stays one document. + ServerCompatibility.warning(profile, serverVersion, global.instanceSelector()).ifPresent(printer::warn); // Try to read image digest from Docker (best-effort) try { diff --git a/src/main/java/io/floci/cli/commands/WaitCommand.java b/src/main/java/io/floci/cli/commands/WaitCommand.java index a9ed3a0..030db5a 100644 --- a/src/main/java/io/floci/cli/commands/WaitCommand.java +++ b/src/main/java/io/floci/cli/commands/WaitCommand.java @@ -70,6 +70,12 @@ public class WaitCommand implements Callable { */ String knownEndpoint; + /** + * Set by {@code start}, which reports the outcome in its own structured result: this wait + * then prints no document of its own, so stdout carries exactly one. + */ + boolean embedded; + static final long FIRST_DELAY_MS = 25; static final long MAX_DELAY_MS = 500; static final Duration MAX_REQUEST_TIMEOUT = Duration.ofSeconds(10); @@ -99,7 +105,7 @@ public class WaitCommand implements Callable { if (isReady(client, service, requestTimeout(Duration.between(Instant.now(), deadline)))) { if (spinner) clearSpinner(printer); if (printer.format() != OutputFormat.text) { - printer.structured(Map.of("ready", true, "endpoint", effectiveEndpoint)); + if (!embedded) printer.structured(Map.of("ready", true, "endpoint", effectiveEndpoint)); } else { printer.println(Ansi.green(profile.displayName() + " is ready") + " (" + effectiveEndpoint + ")"); } diff --git a/src/main/java/io/floci/cli/commands/config/ComposeCheck.java b/src/main/java/io/floci/cli/commands/config/ComposeCheck.java new file mode 100644 index 0000000..18e6520 --- /dev/null +++ b/src/main/java/io/floci/cli/commands/config/ComposeCheck.java @@ -0,0 +1,267 @@ +package io.floci.cli.commands.config; + +import com.fasterxml.jackson.databind.JsonNode; +import io.floci.cli.ProductProfile; +import io.floci.cli.doctor.checks.ImageVersionCheck; +import io.floci.cli.update.Version; + +import java.nio.file.Files; +import java.nio.file.InvalidPathException; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * What {@code config validate} finds in a Compose file. It reads the parsed document and looks + * at the one service that runs the product's emulator, so a port or a volume on some other + * service is never taken for the emulator's. + */ +public final class ComposeCheck { + + /** The directory the emulator keeps its state in, inside the container. */ + static final String DATA_DIR = "/app/data"; + + private ComposeCheck() {} + + /** + * The findings for one file. {@code service} is the Compose service that was checked, or null + * when none could be told apart as the emulator's. + */ + public record Report(String service, List errors, List warnings) { + + public boolean valid() { + return errors.isEmpty(); + } + } + + /** Where the emulator looks for the Docker socket, inside the container. */ + static final String DOCKER_SOCK = "/var/run/docker.sock"; + + /** + * A volume entry, from either the short {@code src:dst[:mode]} or the long form. {@code bind} + * is true when the source is a path on the host rather than a named volume. + */ + record Mount(String source, String target, boolean readOnly, boolean bind) {} + + /** + * @param baseDir the Compose file's directory, against which relative bind sources resolve + */ + public static Report analyze(JsonNode compose, ProductProfile profile, boolean dockerSockRequired, + String dockerSockNeededFor, Path baseDir) { + List errors = new ArrayList<>(); + List warnings = new ArrayList<>(); + JsonNode services = compose.path("services"); + if (!services.isObject() || services.isEmpty()) { + errors.add("No services found: a Compose file needs a 'services' section with the " + + profile.displayName() + " service in it"); + return new Report(null, errors, warnings); + } + + String ghcrImage = "ghcr.io/floci-io/" + profile.image().substring(profile.image().indexOf('/') + 1); + Map.Entry found = null; + for (Map.Entry service : services.properties()) { + String repository = repositoryOf(service.getValue().path("image").asText("")); + if (repository.equals(profile.image()) || repository.equals("docker.io/" + profile.image()) + || repository.equals(ghcrImage)) { + found = service; + break; + } + } + if (found == null) { + warnings.add(profile.displayName() + " image reference not detected — ensure your service uses " + + profile.image() + " or " + ghcrImage); + // With one service there is no doubt which one is meant (a locally built image, a + // mirror); with several, checking the wrong one would only mislead. + if (services.size() != 1) { + return new Report(null, errors, warnings); + } + found = services.properties().iterator().next(); + } + + JsonNode service = found.getValue(); + List mounts = mounts(service.path("volumes")); + Map environment = environment(service.path("environment")); + int port = profile.defaultPort(); + + // The container side is what the emulator opens; the host side may be any socket (Podman's, + // a rootless Docker's), so only the target is checked. + if (mounts.stream().noneMatch(m -> DOCKER_SOCK.equals(stripTrailingSlash(m.target())))) { + (dockerSockRequired ? errors : warnings) + .add("Missing " + DOCKER_SOCK + " volume mount — required for " + dockerSockNeededFor); + } + + // With host networking the container's ports are the host's; there is nothing to map. + if (!"host".equals(service.path("network_mode").asText("")) && !publishes(service.path("ports"), port)) { + errors.add("No port mapping for " + port + " found — " + profile.displayName() + " listens on " + port + + " inside the container; map any host port to it, for example \"" + port + ":" + port + "\""); + } + + Mount data = mounts.stream().filter(m -> DATA_DIR.equals(stripTrailingSlash(m.target()))).findFirst().orElse(null); + String storageVar = profile.envVar("STORAGE_MODE"); + String storageMode = environment.get(storageVar); + // A value Compose will substitute (${MODE:-persistent}) cannot be judged from here, and + // neither can one an env_file may set: the file is not read. + boolean storageKnown = storageMode == null + ? service.path("env_file").isMissingNode() || service.path("env_file").isNull() + : !storageMode.contains("${"); + if (data != null && storageKnown && !"persistent".equalsIgnoreCase(storageMode)) { + warnings.add("A volume is mounted at " + DATA_DIR + " but " + storageVar + " is not 'persistent' — " + + "the emulator keeps its state in memory by default, so the volume stays empty"); + } + if (data == null && "persistent".equalsIgnoreCase(storageMode)) { + warnings.add(storageVar + " is 'persistent' but nothing is mounted at " + DATA_DIR + + " — the state is lost when the container is removed"); + } + if (data != null) { + if (data.readOnly()) { + errors.add("The volume at " + DATA_DIR + " is mounted read-only — the emulator cannot save its state there"); + } + String notADirectory = fileWhereADirectoryIsNeeded(data, baseDir); + if (notADirectory != null) { + errors.add("The volume at " + DATA_DIR + " is bound to " + notADirectory + ", which is a file, not a directory"); + } + } + + String tag = tagOf(service.path("image").asText("")); + // The minimum is the AWS emulator's; the other emulators are versioned on their own lines. + if ("aws".equals(profile.name()) && Version.isValid(tag) + && !ImageVersionCheck.meetsMinimum(tag, ImageVersionCheck.MIN_VERSION)) { + warnings.add("Image tag " + tag + " is older than " + ImageVersionCheck.MIN_VERSION + + ", the oldest version this CLI supports — use a newer tag"); + } + + return new Report(found.getKey(), errors, warnings); + } + + /** {@code registry/name:tag@digest} without its tag and digest. */ + public static String repositoryOf(String image) { + String reference = image.strip(); + int digest = reference.indexOf('@'); + if (digest >= 0) reference = reference.substring(0, digest); + int colon = reference.lastIndexOf(':'); + // A colon before the last slash is a registry port, not a tag. + return colon > reference.lastIndexOf('/') ? reference.substring(0, colon) : reference; + } + + /** The tag of an image reference, or an empty string when it has none. */ + public static String tagOf(String image) { + String reference = image.strip(); + int digest = reference.indexOf('@'); + if (digest >= 0) reference = reference.substring(0, digest); + int colon = reference.lastIndexOf(':'); + return colon > reference.lastIndexOf('/') ? reference.substring(colon + 1) : ""; + } + + /** + * Whether one of a service's {@code ports} entries reaches {@code port} inside the container, + * whatever the host side is: {@code 4566}, {@code "4566:4566"}, {@code "5566:4566"}, + * {@code "127.0.0.1:5566:4566/tcp"}, a range that contains it, or the long form's {@code target}. + */ + public static boolean publishes(JsonNode ports, int port) { + for (JsonNode entry : ports) { + if (entry.isObject()) { + if (entry.path("target").asInt(-1) == port && isTcp(entry.path("protocol").asText(""))) return true; + continue; + } + String text = entry.asText("").strip(); + int slash = text.indexOf('/'); + String protocol = slash >= 0 ? text.substring(slash + 1) : ""; + if (slash >= 0) text = text.substring(0, slash); + String container = text.substring(text.lastIndexOf(':') + 1); + if (isTcp(protocol) && inRange(container, port)) return true; + } + return false; + } + + // The emulator's endpoint is HTTP: a UDP mapping of the same number does not reach it. An + // entry without a protocol is TCP, as Compose reads it. + private static boolean isTcp(String protocol) { + return protocol.isBlank() || "tcp".equalsIgnoreCase(protocol.strip()); + } + + private static boolean inRange(String spec, int port) { + try { + int dash = spec.indexOf('-'); + if (dash < 0) return Integer.parseInt(spec.strip()) == port; + return Integer.parseInt(spec.substring(0, dash).strip()) <= port + && port <= Integer.parseInt(spec.substring(dash + 1).strip()); + } catch (NumberFormatException e) { + return false; // a ${VARIABLE} or something else that is not a number + } + } + + static List mounts(JsonNode volumes) { + List mounts = new ArrayList<>(); + for (JsonNode entry : volumes) { + if (entry.isObject()) { + // In the long form the type says what the source is; a bind's is a host path + // even when it is a bare name like 'data'. + mounts.add(new Mount(entry.path("source").asText(""), entry.path("target").asText(""), + entry.path("read_only").asBoolean(false), "bind".equals(entry.path("type").asText("")))); + continue; + } + String text = entry.asText(""); + // A Windows source (C:\data:/app/data) has a colon of its own after the drive letter. + int from = startsWithDrive(text) ? 2 : 0; + int first = text.indexOf(':', from); + if (first < 0) { + mounts.add(new Mount("", text, false, false)); // an anonymous volume: only the container path + continue; + } + String source = text.substring(0, first); + String rest = text.substring(first + 1); + int second = rest.indexOf(':'); + String target = second < 0 ? rest : rest.substring(0, second); + String mode = second < 0 ? "" : rest.substring(second + 1); + // In the short form a source is a host path when it looks like one; a bare name is a + // named volume. + boolean bind = source.startsWith("/") || source.startsWith(".") || source.startsWith("~") + || startsWithDrive(source); + mounts.add(new Mount(source, target, List.of(mode.split(",")).contains("ro"), bind)); + } + return mounts; + } + + private static boolean startsWithDrive(String text) { + return text.length() > 2 && Character.isLetter(text.charAt(0)) && text.charAt(1) == ':' + && (text.charAt(2) == '\\' || text.charAt(2) == '/'); + } + + /** A service's {@code environment}, from either the mapping or the {@code KEY=value} list form. */ + static Map environment(JsonNode environment) { + Map values = new LinkedHashMap<>(); + if (environment.isObject()) { + for (Map.Entry entry : environment.properties()) { + values.put(entry.getKey(), entry.getValue().asText("")); + } + } else { + for (JsonNode entry : environment) { + String text = entry.asText(""); + int equals = text.indexOf('='); + if (equals > 0) values.put(text.substring(0, equals), text.substring(equals + 1)); + } + } + return values; + } + + private static String stripTrailingSlash(String path) { + return path.length() > 1 && path.endsWith("/") ? path.substring(0, path.length() - 1) : path; + } + + // Best effort: only a bind source that already exists on this machine can be looked at. A + // named volume, a ${VARIABLE}, a home-relative path Compose expands itself, or a path that + // is not there yet says nothing. + private static String fileWhereADirectoryIsNeeded(Mount mount, Path baseDir) { + if (!mount.bind() || mount.source().isBlank() || mount.source().contains("${") || mount.source().startsWith("~")) { + return null; + } + try { + Path path = baseDir.resolve(mount.source()).normalize(); + return Files.isRegularFile(path) ? path.toString() : null; + } catch (InvalidPathException e) { + return null; + } + } +} diff --git a/src/main/java/io/floci/cli/commands/config/ConfigProfileCommand.java b/src/main/java/io/floci/cli/commands/config/ConfigProfileCommand.java index 0e9a190..dd8f1ea 100644 --- a/src/main/java/io/floci/cli/commands/config/ConfigProfileCommand.java +++ b/src/main/java/io/floci/cli/commands/config/ConfigProfileCommand.java @@ -12,6 +12,7 @@ import picocli.CommandLine.*; import picocli.CommandLine.Model.CommandSpec; import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.Comparator; @@ -19,6 +20,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.concurrent.Callable; +import java.util.function.UnaryOperator; @Command( name = "profile", @@ -45,15 +47,23 @@ public class ConfigProfileCommand implements Callable { /** Test seam: a store pointed at a temporary profiles directory. */ public ConfigProfileCommand(ProductProfile profile, ProfileStore store) { + this(profile, store, System::getenv); + } + + /** Test seam: {@code env} answers the {@code VISUAL}/{@code EDITOR} lookup that {@code edit} makes. */ + public ConfigProfileCommand(ProductProfile profile, ProfileStore store, UnaryOperator env) { this.profile = profile; this.store = store; + this.env = env; this.global = new GlobalOptions(profile); } - @Parameters(index = "0", description = "Action: list, show, create, delete", paramLabel = "list|show|create|delete") + private final UnaryOperator env; + + @Parameters(index = "0", description = "Action: list, show, create, edit, delete", paramLabel = "list|show|create|edit|delete") String action; - @Parameters(index = "1", description = "Profile name (required for show, create, delete)", arity = "0..1", paramLabel = "") + @Parameters(index = "1", description = "Profile name (required for show, create, edit, delete)", arity = "0..1", paramLabel = "") String name; // create only. With --container they describe one instance, so several profiles can run the @@ -85,9 +95,10 @@ public class ConfigProfileCommand implements Callable { case "list" -> listProfiles(printer, store); case "show" -> showProfile(printer, store); case "create" -> createProfile(printer, store); + case "edit" -> editProfile(printer, store); case "delete" -> deleteProfile(printer, store); default -> { - printer.error("Unknown action '" + action + "'.\nUse one of: list, show, create, delete."); + printer.error("Unknown action '" + action + "'.\nUse one of: list, show, create, edit, delete."); yield 1; } }; @@ -169,6 +180,124 @@ public class ConfigProfileCommand implements Callable { } } + /** + * Opens the profile's file in the user's editor, then reads it back. The file is the one + * the profile is read from ({@code .yaml} or {@code .yml}); a profile that does not exist is + * not created here, since {@code create} is what writes the product's defaults into it. + */ + private int editProfile(Printer printer, ProfileStore store) { + if (name == null) { printer.error(nameRequired()); return 1; } + String prefix = this.profile.commandPrefix() + " config profile "; + // Asked of the file, not of its contents: a profile that no longer parses is exactly the + // one that has to be opened to be repaired. + Path file = store.existingFile(name); + if (!Files.exists(file)) { + printer.error("Profile '" + name + "' not found.\nRun '" + prefix + "create " + name + "' to create it first."); + return 1; + } + + List editor = editorCommand(env.apply("VISUAL"), env.apply("EDITOR")); + if (editor.isEmpty()) { + printer.error("No editor is set, so " + file + " was not opened.\n" + + "Set EDITOR (for example 'export EDITOR=vi'), or edit the file yourself."); + return 1; + } + List command = new ArrayList<>(editor); + command.add(file.toString()); + int exit; + try { + exit = new ProcessBuilder(command).inheritIO().start().waitFor(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + printer.error("Interrupted while " + editor.get(0) + " was open.\nRe-run '" + prefix + "edit " + name + "'."); + return 1; + } catch (IOException e) { + printer.error("Could not start the editor '" + String.join(" ", editor) + "': " + e.getMessage(), + "Set EDITOR to a command on your PATH, or edit " + file + " yourself."); + return 1; + } + if (exit != 0) { + printer.error("The editor '" + String.join(" ", editor) + "' exited with code " + exit + ".\n" + + "Re-run '" + prefix + "edit " + name + "', or edit " + file + " yourself."); + return 1; + } + + // Read it back: a typo that breaks the YAML should surface now, not on the next start. + try { + var edited = store.get(name); + if (edited.isEmpty()) { + printer.error("Profile '" + name + "' is gone after the edit.\nRun '" + prefix + "create " + name + "' to create it again."); + return 1; + } + ProfileDefaultValueProvider.warnAboutUnknownKeys(store, name, edited.get()); + } catch (IOException e) { + String reason = e.getMessage() == null ? "unreadable" : e.getMessage().lines().findFirst().orElse("unreadable"); + printer.error("Profile '" + name + "' is no longer valid: " + reason + "\n" + + "Re-run '" + prefix + "edit " + name + "' to fix it."); + return 1; + } + printer.println("Profile '" + name + "' saved " + Ansi.gray("(" + file + ")")); + return 0; + } + + /** + * The editor to run, as a command and its arguments: {@code VISUAL} first, then + * {@code EDITOR}, as other tools do. Empty when neither is set. + */ + public static List editorCommand(String visual, String editor) { + String chosen = visual != null && !visual.isBlank() ? visual : editor; + if (chosen == null || chosen.isBlank()) return List.of(); + return words(chosen); + } + + /** + * {@code line} split into words the way a shell would for a simple command: whitespace + * separates, and single and double quotes group (a path with spaces). A backslash is an + * escape only in front of a space or a quote; anywhere else it is an ordinary character, so + * a Windows path ({@code C:\Windows\System32\notepad.exe}, {@code \\server\share\edit}) + * comes through intact. Nothing is expanded; the words go straight to the process, never + * through a shell. + */ + static List words(String line) { + List words = new ArrayList<>(); + StringBuilder word = new StringBuilder(); + boolean inWord = false; + char quote = 0; + for (int i = 0; i < line.length(); i++) { + char c = line.charAt(i); + if (quote != 0) { + if (c == quote) { + quote = 0; + } else if (c == '\\' && quote == '"' && i + 1 < line.length() && line.charAt(i + 1) == '"') { + word.append(line.charAt(++i)); + } else { + word.append(c); + } + } else if (c == '\'' || c == '"') { + quote = c; + inWord = true; + } else if (c == '\\' && i + 1 < line.length() && escapable(line.charAt(i + 1))) { + word.append(line.charAt(++i)); + inWord = true; + } else if (Character.isWhitespace(c)) { + if (inWord) { + words.add(word.toString()); + word.setLength(0); + inWord = false; + } + } else { + word.append(c); + inWord = true; + } + } + if (inWord) words.add(word.toString()); + return List.copyOf(words); + } + + private static boolean escapable(char next) { + return Character.isWhitespace(next) || next == '"' || next == '\''; + } + private int createProfile(Printer printer, ProfileStore store) { if (name == null) { printer.error(nameRequired()); return 1; } try { diff --git a/src/main/java/io/floci/cli/commands/config/ConfigShowCommand.java b/src/main/java/io/floci/cli/commands/config/ConfigShowCommand.java index 1e02600..b6fec64 100644 --- a/src/main/java/io/floci/cli/commands/config/ConfigShowCommand.java +++ b/src/main/java/io/floci/cli/commands/config/ConfigShowCommand.java @@ -51,7 +51,7 @@ public class ConfigShowCommand implements Callable { data.put("profile", global.profile != null ? global.profile : "default"); data.put("endpoint", global.endpoint); data.put("container", global.container); - data.put("output", global.output != null ? global.output.name() : "text"); + data.put("output", global.format() != null ? global.format().name() : "text"); // image/port/persistDir/services have no global option, so they are read back from the // profile itself — they only take effect on 'start'. diff --git a/src/main/java/io/floci/cli/commands/config/ConfigValidateCommand.java b/src/main/java/io/floci/cli/commands/config/ConfigValidateCommand.java index b8c2915..d792f94 100644 --- a/src/main/java/io/floci/cli/commands/config/ConfigValidateCommand.java +++ b/src/main/java/io/floci/cli/commands/config/ConfigValidateCommand.java @@ -1,18 +1,23 @@ package io.floci.cli.commands.config; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import io.floci.cli.GlobalOptions; import io.floci.cli.ProductProfile; import io.floci.cli.output.Ansi; +import io.floci.cli.output.Glyphs; +import io.floci.cli.output.OutputFormat; 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.LinkedHashMap; import java.util.List; +import java.util.Map; import java.util.concurrent.Callable; -import java.util.regex.Pattern; @Command( name = "validate", @@ -21,6 +26,8 @@ import java.util.regex.Pattern; ) public class ConfigValidateCommand implements Callable { + private static final ObjectMapper YAML = new ObjectMapper(new YAMLFactory()); + protected final ProductProfile profile; private final boolean dockerSockRequired; private final String dockerSockNeededFor; @@ -61,50 +68,68 @@ public class ConfigValidateCommand implements Callable { return 1; } - printer.println(Ansi.bold("Validating") + " " + composeFile); + JsonNode compose = null; + String unreadable = null; + try { + compose = YAML.readTree(content); + if (compose == null || !compose.isObject()) { + unreadable = "Could not read " + composeFile + " as a Compose file: it has no top-level mapping"; + } + } catch (IOException e) { + String reason = e.getMessage() == null ? "unreadable" : e.getMessage().lines().findFirst().orElse("unreadable"); + unreadable = "Could not read " + composeFile + " as YAML: " + reason; + } + if (unreadable != null) { + // Structured output always carries the report, so a script reading it gets 'valid: false' + // and the reason rather than nothing. + if (printer.format() != OutputFormat.text) { + printer.structured(document(composeFile, new ComposeCheck.Report(null, List.of(unreadable), List.of()))); + } else { + printer.error(unreadable, "Fix the file's syntax, or pass another with --file."); + } + return 1; + } + + Path baseDir = composeFile.toAbsolutePath().getParent(); + ComposeCheck.Report report = ComposeCheck.analyze(compose, profile, dockerSockRequired, dockerSockNeededFor, baseDir); + + if (printer.format() != OutputFormat.text) { + printer.structured(document(composeFile, report)); + return report.valid() ? 0 : 1; + } + + printer.println(Ansi.bold("Validating") + " " + composeFile + + (report.service() == null ? "" : Ansi.gray(" (service: " + report.service() + ")"))); printer.println(""); - List issues = new ArrayList<>(); - List warnings = new ArrayList<>(); - - // Check for docker.sock mount (an error where the product needs it for core services) - if (!content.contains("/var/run/docker.sock")) { - (dockerSockRequired ? issues : warnings) - .add("Missing /var/run/docker.sock volume mount — required for " + dockerSockNeededFor); + for (String issue : report.errors()) { + printer.println(" " + Ansi.red(Glyphs.fail()) + " " + issue); } - - // Check port mapping - int port = profile.defaultPort(); - if (!Pattern.compile(port + "\\s*:\\s*" + port).matcher(content).find()) { - issues.add("Port mapping " + port + ":" + port + " not found — " + profile.displayName() - + " listens on " + port + " by default"); + for (String warn : report.warnings()) { + printer.println(" " + Ansi.yellow(Glyphs.warn()) + " " + warn); } - - // Check for the product image - String ghcrImage = "ghcr.io/floci-io/" + profile.image().substring(profile.image().indexOf('/') + 1); - if (!content.contains(profile.image()) && !content.contains(ghcrImage)) { - warnings.add(profile.displayName() + " image reference not detected — ensure your service uses " - + profile.image() + " or " + ghcrImage); - } - - 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"); + if (report.errors().isEmpty() && report.warnings().isEmpty()) { + printer.println(" " + Ansi.green(Glyphs.ok()) + " Compose file looks good"); } printer.println(""); - if (!issues.isEmpty()) { - printer.println(issues.size() + " error(s) found."); + if (!report.valid()) { + printer.println(report.errors().size() + " error(s) found."); return 1; } return 0; } + private static Map document(Path composeFile, ComposeCheck.Report report) { + Map out = new LinkedHashMap<>(); + out.put("file", composeFile.toString()); + out.put("service", report.service()); + out.put("valid", report.valid()); + out.put("errors", report.errors()); + out.put("warnings", report.warnings()); + return out; + } + 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")) { diff --git a/src/main/java/io/floci/cli/config/ProfileStore.java b/src/main/java/io/floci/cli/config/ProfileStore.java index a419605..0db2682 100644 --- a/src/main/java/io/floci/cli/config/ProfileStore.java +++ b/src/main/java/io/floci/cli/config/ProfileStore.java @@ -98,6 +98,10 @@ public class ProfileStore { // The one read path, so list and show agree on a profile's name. private static Profile read(Path file) throws IOException { Profile profile = YAML.readValue(file.toFile(), Profile.class); + // 'null' and '~' are valid YAML for "nothing": a document, but not a profile. + if (profile == null) { + throw new IOException(file + " holds no settings: it has to be a mapping, like 'port: 4566'"); + } // Hand-written files often omit 'name:'; the file name is the name. if (profile.name == null || profile.name.isBlank()) { profile.name = nameOf(file); diff --git a/src/main/java/io/floci/cli/docker/DockerClient.java b/src/main/java/io/floci/cli/docker/DockerClient.java index b07b146..0d0e264 100644 --- a/src/main/java/io/floci/cli/docker/DockerClient.java +++ b/src/main/java/io/floci/cli/docker/DockerClient.java @@ -8,6 +8,7 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.io.PrintStream; import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; @@ -67,18 +68,10 @@ public class DockerClient { private static final ObjectMapper JSON = new ObjectMapper(); public Optional inspectRunSettings(String name, int containerPort) throws DockerException { - String out; + Optional document = inspectDocument(name); + if (document.isEmpty()) return Optional.empty(); try { - out = run("docker", "container", "inspect", "--format", "{{json .}}", "--", name); - } catch (DockerException e) { - if (e.getMessage() != null && e.getMessage().toLowerCase().contains("no such")) { - return Optional.empty(); - } - throw e; - } - if (out.isBlank()) return Optional.empty(); - try { - JsonNode c = JSON.readTree(out); + JsonNode c = document.get(); String image = textOrNull(c.path("Config").path("Image")); Integer hostPort = null; JsonNode binding = c.path("HostConfig").path("PortBindings").path(containerPort + "/tcp"); @@ -133,26 +126,56 @@ public class DockerClient { } public Optional inspectContainer(String name) throws DockerException { + Optional document = inspectDocument(name); + if (document.isEmpty()) return Optional.empty(); + JsonNode c = document.get(); + String reported = c.path("Name").asText("").replaceFirst("^/", ""); + return Optional.of(new ContainerInfo( + c.path("Id").asText(""), + reported.isBlank() ? name : reported, + c.path("Config").path("Image").asText(""), + c.path("State").path("Status").asText(""), + publishedPorts(c.path("NetworkSettings").path("Ports")))); + } + + /** + * The published ports of an inspect document as {@code "14566->4566/tcp 18080->8080/tcp"}: + * host port, then the container side. A port that is exposed but not published has no + * binding and is left out. + */ + public static String publishedPorts(JsonNode ports) { + StringBuilder published = new StringBuilder(); + for (var port : ports.properties()) { + JsonNode bindings = port.getValue(); + if (!bindings.isArray() || bindings.isEmpty()) continue; + String hostPort = bindings.get(0).path("HostPort").asText(""); + if (hostPort.isBlank()) continue; + if (!published.isEmpty()) published.append(' '); + published.append(hostPort).append("->").append(port.getKey()); + } + return published.toString(); + } + + // The container's whole inspect document, or empty when there is no such container. One + // JSON read serves every caller; a field-by-field Go template had to be split on a + // delimiter, which a value could contain. + private Optional inspectDocument(String name) throws DockerException { + String out; try { - String out = run("docker", "container", "inspect", - "--format", - "{{.Id}}|{{.Name}}|{{.Config.Image}}|{{.State.Status}}|" + - "{{range $p, $b := .NetworkSettings.Ports}}{{if $b}}{{(index $b 0).HostPort}}->{{$p}} {{end}}{{end}}", - "--", name); - if (out.isBlank()) return Optional.empty(); - String[] parts = out.trim().split("\\|", -1); - return Optional.of(new ContainerInfo( - parts.length > 0 ? parts[0] : "", // id - parts.length > 1 ? parts[1].replaceFirst("^/", "") : name, - parts.length > 2 ? parts[2] : "", // image - parts.length > 3 ? parts[3] : "", // status - parts.length > 4 ? parts[4].trim() : "")); // ports + out = run("docker", "container", "inspect", "--format", "{{json .}}", "--", name); } catch (DockerException e) { if (e.getMessage() != null && e.getMessage().toLowerCase().contains("no such")) { return Optional.empty(); } throw e; } + if (out.isBlank()) return Optional.empty(); + try { + return Optional.of(JSON.readTree(out)); + } catch (Exception e) { + throw new DockerException("Could not read the details of container '" + name + "': " + e.getMessage() + + "\n" + CHECK_DOCKER); + } } public boolean isImagePresent(String image) throws DockerException { @@ -186,9 +209,17 @@ public class DockerClient { } public void pull(String image, String policy) throws DockerException { + pull(image, policy, System.out); + } + + /** + * {@link #pull(String, String)} with docker's progress written to {@code progress}. A command + * printing structured output sends it to stderr, so stdout stays one parseable document. + */ + public void pull(String image, String policy, PrintStream progress) throws DockerException { if ("never".equalsIgnoreCase(policy)) return; if ("missing".equalsIgnoreCase(policy) && isImagePresent(image)) return; - runStreaming("docker", "pull", "--", image); + runStreaming(progress, "docker", "pull", "--", image); } public String startContainer(List args) throws DockerException { @@ -227,7 +258,7 @@ public class DockerClient { if (since != null && !since.isBlank()) { cmd.add("--since"); cmd.add(since); } cmd.add("--"); cmd.add(name); - runStreaming(cmd.toArray(String[]::new)); + runStreaming(System.out, cmd.toArray(String[]::new)); } private String run(String... cmd) throws DockerException { @@ -282,7 +313,7 @@ public class DockerClient { return words.toString(); } - private void runStreaming(String... cmd) throws DockerException { + private void runStreaming(PrintStream stdout, String... cmd) throws DockerException { Process proc = null; boolean finished = false; try { @@ -290,7 +321,7 @@ public class DockerClient { proc = started; Thread out = new Thread(() -> { try (var reader = new BufferedReader(new InputStreamReader(started.getInputStream()))) { - reader.lines().forEach(System.out::println); + reader.lines().forEach(stdout::println); } catch (IOException ignored) {} }); Thread err = new Thread(() -> { diff --git a/src/main/java/io/floci/cli/doctor/checks/ImageVersionCheck.java b/src/main/java/io/floci/cli/doctor/checks/ImageVersionCheck.java index 6cc1936..f267a41 100644 --- a/src/main/java/io/floci/cli/doctor/checks/ImageVersionCheck.java +++ b/src/main/java/io/floci/cli/doctor/checks/ImageVersionCheck.java @@ -15,7 +15,8 @@ public class ImageVersionCheck implements Check { private final String image; private final DockerClient docker; - private static final String MIN_VERSION = "1.5.0"; + /** The oldest server version this CLI supports. */ + public static final String MIN_VERSION = "1.5.0"; public ImageVersionCheck() { this("floci/floci"); diff --git a/src/main/java/io/floci/cli/output/Glyphs.java b/src/main/java/io/floci/cli/output/Glyphs.java new file mode 100644 index 0000000..c6495b3 --- /dev/null +++ b/src/main/java/io/floci/cli/output/Glyphs.java @@ -0,0 +1,31 @@ +package io.floci.cli.output; + +/** + * The marks commands put in front of a line. Like {@link Ansi}, the choice is made once per + * invocation: Unicode for a person at a terminal, plain ASCII with {@code --no-emoji}, when the + * output is piped, or when {@code NO_COLOR} asks for undecorated output. + */ +public final class Glyphs { + + /** One set of marks. */ + public record Set(String ok, String warn, String fail, String arrow) {} + + public static final Set UNICODE = new Set("✓", "⚠", "✗", "→"); + public static final Set ASCII = new Set("+", "!", "x", "->"); + + private static Set current = UNICODE; + + private Glyphs() {} + + /** Switches to plain ASCII for the rest of this invocation; it cannot be switched back. */ + public static void plain() { + current = ASCII; + } + + public static String ok() { return current.ok(); } + public static String warn() { return current.warn(); } + public static String fail() { return current.fail(); } + public static String arrow() { return current.arrow(); } + + public static boolean isPlain() { return current == ASCII; } +} diff --git a/src/test/java/io/floci/cli/unit/ActionOutputTest.java b/src/test/java/io/floci/cli/unit/ActionOutputTest.java new file mode 100644 index 0000000..85fe29f --- /dev/null +++ b/src/test/java/io/floci/cli/unit/ActionOutputTest.java @@ -0,0 +1,400 @@ +package io.floci.cli.unit; + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MappingIterator; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import com.sun.net.httpserver.HttpServer; +import io.floci.cli.ProductProfile; +import io.floci.cli.commands.RestartCommand; +import io.floci.cli.commands.StartCommand; +import io.floci.cli.commands.StatusCommand; +import io.floci.cli.commands.StopCommand; +import io.floci.cli.config.ProfileDefaultValueProvider; +import io.floci.cli.config.ProfileStore; +import io.floci.cli.docker.DockerClient; +import io.floci.cli.docker.DockerClient.DockerHost; +import io.floci.cli.docker.DockerClient.Kind; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; +import picocli.CommandLine; + +import java.io.ByteArrayOutputStream; +import java.io.OutputStream; +import java.io.PrintStream; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.ServerSocket; +import java.nio.charset.StandardCharsets; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.Callable; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * BL-056 and BL-057: start, stop and restart print one structured document with -o json/yaml and + * nothing else on stdout, and status says through its exit code whether the instance is up. + */ +class ActionOutputTest { + + // A remote daemon, so start does not probe the local port its own stub server listens on. + private static final DockerHost REMOTE = new DockerHost(Kind.TCP, null, "tcp://build-host:2375"); + // One document and nothing after it: a second value on stdout fails the parse. + private static final ObjectMapper JSON = new ObjectMapper().enable(DeserializationFeature.FAIL_ON_TRAILING_TOKENS); + private static final ObjectMapper YAML = new ObjectMapper(new YAMLFactory()); + + /** The single YAML document on {@code stdout}; fails when there are several, or none. */ + private static JsonNode oneYamlDocument(String stdout) throws Exception { + List documents = new ArrayList<>(); + try (MappingIterator all = YAML.readerFor(JsonNode.class).readValues(stdout)) { + all.forEachRemaining(documents::add); + } + assertEquals(1, documents.size(), "exactly one YAML document on stdout: " + stdout); + assertTrue(documents.get(0).isObject(), stdout); + return documents.get(0); + } + + @TempDir + Path tempDir; + + private HttpServer emulator; + private int port; + + @BeforeEach + void startEmulatorStub() throws Exception { + emulator = HttpServer.create(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0); + emulator.createContext("/", exchange -> { + byte[] body = "{\"version\":\"1.6.0\",\"edition\":\"community\",\"services\":[\"s3\"]}".getBytes(StandardCharsets.UTF_8); + exchange.sendResponseHeaders(200, body.length); + try (OutputStream out = exchange.getResponseBody()) { + out.write(body); + } + exchange.close(); + }); + emulator.start(); + port = emulator.getAddress().getPort(); + } + + @AfterEach + void stopEmulatorStub() { + emulator.stop(0); + } + + /** A docker that holds one container (or none) and records what was asked of it. */ + private static class FakeDocker extends DockerClient { + final List calls = new ArrayList<>(); + String state; // null: no such container + String ports = ""; + + FakeDocker(String state) { + this.state = state; + } + + @Override + public DockerHost daemonHost() { + return REMOTE; + } + + @Override + public Optional inspectContainer(String name) { + return state == null ? Optional.empty() + : Optional.of(new ContainerInfo("abc123", name, "floci/floci:latest", state, ports)); + } + + @Override + public Optional inspectRunSettings(String name, int containerPort) { + return Optional.empty(); + } + + @Override + public void pull(String image, String policy) { + calls.add("pull:stdout"); + System.out.println("latest: Pulling from floci/floci"); + } + + @Override + public void pull(String image, String policy, PrintStream progress) { + calls.add("pull:" + (progress == System.err ? "stderr" : "other")); + progress.println("latest: Pulling from floci/floci"); + } + + @Override + public String startContainer(List args) { + calls.add("run"); + state = "running"; + return "0123456789abcdef0123"; + } + + @Override + public void stopContainer(String name, int timeout) { + calls.add("stop"); + state = "exited"; + } + + @Override + public void removeContainer(String name) { + calls.add("rm"); + state = null; + } + } + + private record Run(int exit, String out, String err) {} + + private Run execute(Callable command, String... args) { + PrintStream out = System.out; + PrintStream err = System.err; + ByteArrayOutputStream outBuf = new ByteArrayOutputStream(); + ByteArrayOutputStream errBuf = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outBuf)); + System.setErr(new PrintStream(errBuf)); + try { + int exit = new CommandLine(command) + .setDefaultValueProvider(new ProfileDefaultValueProvider(new ProfileStore(tempDir))) + .execute(args); + return new Run(exit, outBuf.toString(), errBuf.toString()); + } finally { + System.setOut(out); + System.setErr(err); + } + } + + private String[] startArgs(String... more) { + List args = new ArrayList<>(List.of("--port", String.valueOf(port), "--container", "floci-actions")); + args.addAll(List.of(more)); + return args.toArray(String[]::new); + } + + // ---- start ----------------------------------------------------------------------------------- + + @Test + void startPrintsOneJsonDocumentAndKeepsProgressOffStdout() throws Exception { + FakeDocker docker = new FakeDocker(null); + + Run r = execute(new StartCommand(ProductProfile.AWS, docker), startArgs("-o", "json", "--pull", "always")); + + assertEquals(0, r.exit(), r.err()); + JsonNode json = JSON.readTree(r.out()); // fails if anything but the document is on stdout + assertEquals("floci-actions", json.path("container").asText()); + assertEquals("0123456789abcdef0123", json.path("id").asText()); + assertEquals("floci/floci:latest", json.path("image").asText()); + assertEquals("http://localhost:" + port, json.path("endpoint").asText()); + assertEquals("running", json.path("state").asText()); + assertTrue(json.path("ready").asBoolean()); + assertEquals(List.of("pull:stderr", "run"), docker.calls); + assertTrue(r.err().contains("Pulling from"), "docker's pull progress goes to stderr: " + r.err()); + assertFalse(r.out().contains("Starting"), r.out()); + } + + @Test + void aDetachedStartReportsNoReadiness() throws Exception { + Run r = execute(new StartCommand(ProductProfile.AWS, new FakeDocker(null)), startArgs("-o", "json", "--detach")); + + assertEquals(0, r.exit(), r.err()); + JsonNode json = JSON.readTree(r.out()); + assertEquals("running", json.path("state").asText()); + assertFalse(json.has("ready"), "readiness was not waited for: " + r.out()); + } + + @Test + void startInYamlIsOneDocumentToo() throws Exception { + Run r = execute(new StartCommand(ProductProfile.AWS, new FakeDocker(null)), startArgs("-o", "yaml", "--detach")); + + assertEquals(0, r.exit(), r.err()); + JsonNode yaml = oneYamlDocument(r.out()); + assertEquals("floci-actions", yaml.path("container").asText()); + assertEquals("running", yaml.path("state").asText()); + assertEquals(5, yaml.size(), "container, id, image, endpoint, state: " + r.out()); + } + + @Test + void anythingExtraOnStdoutFailsTheseTests() { + assertThrows(Exception.class, () -> JSON.readTree("{\"a\":1}\n{\"b\":2}\n")); + assertThrows(Exception.class, () -> JSON.readTree("{\"a\":1}\nStarting...\n")); + assertThrows(AssertionError.class, () -> oneYamlDocument("a: 1\n---\nb: 2\n")); + } + + /** A container that died while start waited for it is reported as it is, not as running. */ + @Test + void aContainerThatExitedDuringTheWaitIsNotReportedRunning() throws Exception { + emulator.stop(0); // nothing answers the readiness poll + FakeDocker docker = new FakeDocker(null) { + @Override + public String startContainer(List args) { + String id = super.startContainer(args); + state = "exited"; // it crashed right after docker run returned + return id; + } + }; + StartCommand start = new StartCommand(ProductProfile.AWS, docker) { + @Override + protected String readinessTimeout() { + return "300ms"; + } + }; + + Run r = execute(start, startArgs("-o", "json")); + + assertEquals(1, r.exit()); + JsonNode json = JSON.readTree(r.out()); + assertEquals("exited", json.path("state").asText()); + assertFalse(json.path("ready").asBoolean()); + } + + /** Text output is what it was: the progress lines, and docker's pull output on stdout. */ + @Test + void startInTextStillNarrates() { + FakeDocker docker = new FakeDocker(null); + + Run r = execute(new StartCommand(ProductProfile.AWS, docker), startArgs("--detach", "--pull", "always")); + + assertEquals(0, r.exit(), r.err()); + assertTrue(r.out().contains("Container started"), r.out()); + assertTrue(r.out().contains("Detached."), r.out()); + assertEquals(List.of("pull:stdout", "run"), docker.calls); + assertFalse(r.out().contains("\"container\""), r.out()); + } + + // ---- stop ------------------------------------------------------------------------------------ + + @ParameterizedTest + @CsvSource({"false, exited, stop", "true, removed, stop;rm"}) + void stopReportsWhatItDid(boolean remove, String state, String calls) throws Exception { + FakeDocker docker = new FakeDocker("running"); + List args = new ArrayList<>(List.of("-o", "json", "--container", "floci-actions")); + if (remove) args.add("--remove"); + + Run r = execute(new StopCommand(ProductProfile.AWS, docker), args.toArray(String[]::new)); + + assertEquals(0, r.exit(), r.err()); + JsonNode json = JSON.readTree(r.out()); + assertEquals("floci-actions", json.path("container").asText()); + assertEquals(state, json.path("state").asText()); + assertTrue(json.path("stopped").asBoolean()); + assertEquals(remove, json.path("removed").asBoolean()); + assertEquals(List.of(calls.split(";")), docker.calls); + } + + /** A container run with docker's --rm is gone once it stops, whatever --remove said. */ + @ParameterizedTest + @CsvSource({"false", "true"}) + void aContainerDockerRemovesItselfIsReportedRemoved(boolean remove) throws Exception { + FakeDocker docker = new FakeDocker("running") { + @Override + public void stopContainer(String name, int timeout) { + calls.add("stop"); + state = null; // --rm: docker removed it + } + }; + List args = new ArrayList<>(List.of("-o", "json")); + if (remove) args.add("--remove"); + + Run r = execute(new StopCommand(ProductProfile.AWS, docker), args.toArray(String[]::new)); + + assertEquals(0, r.exit(), r.err()); + JsonNode json = JSON.readTree(r.out()); + assertEquals("removed", json.path("state").asText()); + assertTrue(json.path("removed").asBoolean()); + assertEquals(List.of("stop"), docker.calls, "nothing left to remove"); + } + + @Test + void stoppingAContainerThatIsNotRunningSaysSo() throws Exception { + Run r = execute(new StopCommand(ProductProfile.AWS, new FakeDocker("exited")), "-o", "json"); + + assertEquals(0, r.exit(), r.err()); + JsonNode json = JSON.readTree(r.out()); + assertEquals("exited", json.path("state").asText()); + assertFalse(json.path("stopped").asBoolean()); + assertFalse(json.path("removed").asBoolean()); + } + + @Test + void stopInTextStillNarrates() { + Run r = execute(new StopCommand(ProductProfile.AWS, new FakeDocker("running")), "--remove"); + + assertTrue(r.out().contains("Stopped."), r.out()); + assertTrue(r.out().contains("Container removed."), r.out()); + } + + // ---- restart --------------------------------------------------------------------------------- + + /** A restart is a stop and a start, but its structured output is the one document of the start. */ + @Test + void restartPrintsOneDocument() throws Exception { + FakeDocker docker = new FakeDocker("running"); + docker.ports = port + "->4566/tcp"; + RestartCommand restart = new RestartCommand(ProductProfile.AWS, docker) { + @Override + public StartCommand buildStartCommand() { + StartCommand start = new StartCommand(ProductProfile.AWS, docker); + new CommandLine(start).parseArgs(startArgs("-o", "json")); + return start; + } + }; + + Run r = execute(restart, "-o", "json", "--container", "floci-actions"); + + assertEquals(0, r.exit(), r.err()); + JsonNode json = JSON.readTree(r.out()); + assertEquals("running", json.path("state").asText()); + assertTrue(json.path("ready").asBoolean()); + assertEquals(List.of("stop", "rm", "pull:stderr", "run"), docker.calls); + } + + // ---- status ---------------------------------------------------------------------------------- + + @ParameterizedTest + @CsvSource({ + "running, true, 0", + "running, false, 1", + "exited, false, 1", + "exited, true, 1", // something else answers there; this container is down + "not found, true, 0", // a remote endpoint, or a Compose service under another name + "not found, false, 1", + "'error: Cannot connect to the Docker daemon', true, 0", + "'error: Cannot connect to the Docker daemon', false, 1"}) + void statusExitCodeSaysWhetherTheInstanceIsUp(String state, boolean reachable, int exit) { + assertEquals(exit, StatusCommand.exitCode(state, reachable)); + } + + @Test + void statusOfARunningInstanceExitsZero() throws Exception { + FakeDocker docker = new FakeDocker("running"); + docker.ports = port + "->4566/tcp"; + + Run json = execute(new StatusCommand(ProductProfile.AWS, docker), "-o", "json"); + Run text = execute(new StatusCommand(ProductProfile.AWS, docker)); + + assertEquals(0, json.exit(), json.err()); + assertTrue(JSON.readTree(json.out()).path("reachable").asBoolean()); + assertEquals(0, text.exit()); + assertTrue(text.out().contains("Reachable: yes"), text.out()); + } + + @Test + void statusOfAnInstanceThatIsDownExitsOneInEveryFormat() throws Exception { + int closed; + try (ServerSocket socket = new ServerSocket(0, 1, InetAddress.getLoopbackAddress())) { + closed = socket.getLocalPort(); + } + FakeDocker docker = new FakeDocker(null); + String endpoint = "http://127.0.0.1:" + closed; + + Run json = execute(new StatusCommand(ProductProfile.AWS, docker), "-o", "json", "--endpoint", endpoint); + Run text = execute(new StatusCommand(ProductProfile.AWS, docker), "--endpoint", endpoint); + + assertEquals(1, json.exit()); + assertFalse(JSON.readTree(json.out()).path("reachable").asBoolean()); + assertEquals("not found", JSON.readTree(json.out()).path("state").asText()); + assertEquals(1, text.exit()); + assertTrue(text.out().contains("floci start"), text.out()); + } +} diff --git a/src/test/java/io/floci/cli/unit/CompletionCommandTest.java b/src/test/java/io/floci/cli/unit/CompletionCommandTest.java new file mode 100644 index 0000000..7a5403d --- /dev/null +++ b/src/test/java/io/floci/cli/unit/CompletionCommandTest.java @@ -0,0 +1,72 @@ +package io.floci.cli.unit; + +import io.floci.cli.FlociCli; +import io.floci.cli.config.ProfileStore; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import picocli.CommandLine; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.nio.file.Path; + +import static org.junit.jupiter.api.Assertions.*; + +/** BL-054: completion offers the shells it can generate a script for, and only those. */ +class CompletionCommandTest { + + @TempDir + Path tempDir; + + private record Run(int exit, String out, String err) {} + + private Run run(String... args) { + PrintStream out = System.out; + PrintStream err = System.err; + ByteArrayOutputStream outBuf = new ByteArrayOutputStream(); + ByteArrayOutputStream errBuf = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outBuf)); + System.setErr(new PrintStream(errBuf)); + try { + int exit = FlociCli.buildCommandLine(new ProfileStore(tempDir)).execute(args); + return new Run(exit, outBuf.toString(), errBuf.toString()); + } finally { + System.setOut(out); + System.setErr(err); + } + } + + @Test + void theHelpListsOnlyTheShellsThatWork() { + CommandLine completion = FlociCli.buildCommandLine(new ProfileStore(tempDir)).getSubcommands().get("completion"); + + assertEquals("bash|zsh", completion.getCommandSpec().positionalParameters().get(0).paramLabel()); + String usage = completion.getUsageMessage(CommandLine.Help.Ansi.OFF); + assertFalse(usage.contains("fish"), usage); + assertFalse(usage.contains("powershell"), usage); + } + + @ParameterizedTest + @ValueSource(strings = {"bash", "zsh", "BASH"}) + void aSupportedShellGetsAScript(String shell) { + Run r = run("completion", shell); + + assertEquals(0, r.exit(), r.err()); + assertTrue(r.out().contains("floci"), "a completion script for the floci command"); + assertEquals("", r.err()); + } + + /** A shell there is no script for is a usage error, and nothing is written to stdout to be sourced. */ + @ParameterizedTest + @ValueSource(strings = {"fish", "powershell", "nushell"}) + void anUnsupportedShellIsAUsageError(String shell) { + Run r = run("completion", shell); + + assertEquals(2, r.exit()); + assertEquals("", r.out()); + assertTrue(r.err().contains("Shell '" + shell + "' is not supported."), r.err()); + assertTrue(r.err().contains("Use bash or zsh."), r.err()); + } +} diff --git a/src/test/java/io/floci/cli/unit/ConfigValidateTest.java b/src/test/java/io/floci/cli/unit/ConfigValidateTest.java new file mode 100644 index 0000000..4b7144c --- /dev/null +++ b/src/test/java/io/floci/cli/unit/ConfigValidateTest.java @@ -0,0 +1,452 @@ +package io.floci.cli.unit; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import io.floci.cli.FlociCli; +import io.floci.cli.ProductProfile; +import io.floci.cli.commands.config.ComposeCheck; +import io.floci.cli.config.ProfileStore; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.*; + +/** BL-055: config validate reads the Compose file's structure and checks the emulator's own service. */ +class ConfigValidateTest { + + private static final ObjectMapper YAML = new ObjectMapper(new YAMLFactory()); + private static final String NEEDED_FOR = "Lambda, EC2"; + + @TempDir + Path tempDir; + + private ComposeCheck.Report aws(String compose) throws Exception { + return ComposeCheck.analyze(YAML.readTree(compose), ProductProfile.AWS, true, NEEDED_FOR, tempDir); + } + + private static String service(String ports, String extra) { + return """ + services: + floci: + image: floci/floci:latest + ports: + - %s + volumes: + - /var/run/docker.sock:/var/run/docker.sock + %s""".formatted(ports, extra); + } + + @Test + void aCompleteServiceHasNothingToReport() throws Exception { + ComposeCheck.Report r = aws(service("\"4566:4566\"", "")); + + assertEquals("floci", r.service()); + assertEquals(List.of(), r.errors()); + assertEquals(List.of(), r.warnings()); + assertTrue(r.valid()); + } + + /** Any host port works: only the container side has to be the emulator's port. */ + @ParameterizedTest + @ValueSource(strings = {"\"4566:4566\"", "\"5566:4566\"", "\"127.0.0.1:5566:4566\"", "\"5566:4566/tcp\"", + "4566", "\"4566\"", "\"14510-14600:4510-4600\"", "{target: 4566, published: 5566}", + "{target: 4566, published: \"5566\", protocol: tcp}"}) + void everyWayOfMappingTheEmulatorPortIsAccepted(String ports) throws Exception { + assertEquals(List.of(), aws(service(ports, "")).errors(), ports); + } + + @ParameterizedTest + @ValueSource(strings = {"\"4566:8080\"", "\"8080:8080\"", "\"45660:45660\"", "8080", "{target: 8080, published: 4566}", + "\"${HOST_PORT}:${CONTAINER_PORT}\""}) + void aMappingThatDoesNotReachTheEmulatorPortIsAnError(String ports) throws Exception { + List errors = aws(service(ports, "")).errors(); + + assertEquals(1, errors.size(), errors.toString()); + assertTrue(errors.get(0).startsWith("No port mapping for 4566 found"), errors.get(0)); + } + + /** The emulator's endpoint is HTTP: a UDP mapping of the same number does not reach it. */ + @ParameterizedTest + @ValueSource(strings = {"\"4566:4566/udp\"", "{target: 4566, published: 5566, protocol: udp}", "\"5566:4566/sctp\""}) + void aMappingThatIsNotTcpIsAnError(String ports) throws Exception { + List errors = aws(service(ports, "")).errors(); + + assertEquals(1, errors.size(), errors.toString()); + assertTrue(errors.get(0).startsWith("No port mapping for 4566 found"), errors.get(0)); + } + + @ParameterizedTest + @ValueSource(strings = {"\"4566:4566/TCP\"", "{target: 4566, published: 5566, protocol: tcp}", "{target: 4566}"}) + void tcpIsAcceptedHoweverItIsSpelled(String ports) throws Exception { + assertEquals(List.of(), aws(service(ports, "")).errors(), ports); + } + + /** What matters is where the socket lands in the container; the host side may be any socket. */ + @ParameterizedTest + @ValueSource(strings = {"/run/user/1000/podman/podman.sock:/var/run/docker.sock", "/var/run/docker.sock:/var/run/docker.sock:ro", + "{type: bind, source: /var/run/docker.sock, target: /var/run/docker.sock}"}) + void aSocketMountedAtTheExpectedPathIsAccepted(String volume) throws Exception { + assertEquals(List.of(), aws(service("\"4566:4566\"", "").replace("/var/run/docker.sock:/var/run/docker.sock", volume)).errors()); + } + + @ParameterizedTest + @ValueSource(strings = {"./notdocker.sock:/tmp/notdocker.sock", "/var/run/docker.sock:/tmp/docker.sock", + "{type: bind, source: /var/run/docker.sock, target: /run/docker.sock}"}) + void aSocketMountedSomewhereElseDoesNotCount(String volume) throws Exception { + List errors = aws(service("\"4566:4566\"", "").replace("/var/run/docker.sock:/var/run/docker.sock", volume)).errors(); + + assertEquals(1, errors.size(), errors.toString()); + assertTrue(errors.get(0).startsWith("Missing /var/run/docker.sock volume mount"), errors.get(0)); + } + + @Test + void hostNetworkingNeedsNoPortMapping() throws Exception { + ComposeCheck.Report r = aws(""" + services: + floci: + image: floci/floci:latest + network_mode: host + volumes: ["/var/run/docker.sock:/var/run/docker.sock"] + """); + + assertEquals(List.of(), r.errors()); + } + + /** Another service's port or socket mount must not satisfy the emulator's checks. */ + @Test + void onlyTheEmulatorsOwnServiceCounts() throws Exception { + ComposeCheck.Report r = aws(""" + services: + proxy: + image: nginx + ports: ["4566:4566"] + volumes: ["/var/run/docker.sock:/var/run/docker.sock"] + floci: + image: ghcr.io/floci-io/floci:1.6.0 + """); + + assertEquals("floci", r.service()); + assertEquals(2, r.errors().size(), r.errors().toString()); + assertTrue(r.errors().get(0).contains("docker.sock"), r.errors().toString()); + assertTrue(r.errors().get(1).contains("No port mapping for 4566"), r.errors().toString()); + } + + @Test + void theSocketIsOnlyAWarningWhereTheProductDoesNotNeedIt() throws Exception { + JsonNode compose = YAML.readTree(""" + services: + gcp: + image: floci/floci-gcp:latest + ports: ["4588:4588"] + """); + + ComposeCheck.Report r = ComposeCheck.analyze(compose, ProductProfile.GCP, false, "Cloud Run", tempDir); + + assertTrue(r.valid()); + assertEquals(1, r.warnings().size()); + assertTrue(r.warnings().get(0).contains("docker.sock"), r.warnings().toString()); + } + + @Test + void theLongVolumeFormIsRead() throws Exception { + ComposeCheck.Report r = aws(""" + services: + floci: + image: floci/floci + ports: ["4566:4566"] + volumes: + - type: bind + source: /var/run/docker.sock + target: /var/run/docker.sock + """); + + assertEquals(List.of(), r.errors()); + } + + // ---- storage mode and the data volume ---------------------------------------------------- + + @Test + void aDataVolumeWithoutPersistentStorageIsFlagged() throws Exception { + ComposeCheck.Report r = aws(service("\"4566:4566\"", " - ./data:/app/data\n")); + + assertTrue(r.valid()); + assertEquals(1, r.warnings().size(), r.warnings().toString()); + assertTrue(r.warnings().get(0).contains("FLOCI_STORAGE_MODE is not 'persistent'"), r.warnings().get(0)); + } + + @ParameterizedTest + @ValueSource(strings = {""" + environment: + FLOCI_STORAGE_MODE: persistent + """, """ + environment: + - FLOCI_STORAGE_MODE=persistent + """, """ + environment: + FLOCI_STORAGE_MODE: ${MODE:-memory} + """}) + void aDataVolumeWithPersistentStorageIsFine(String environment) throws Exception { + ComposeCheck.Report r = aws(service("\"4566:4566\"", " - floci-data:/app/data\n" + environment)); + + assertEquals(List.of(), r.warnings(), environment); + } + + /** An env_file may set the storage mode; it is not read, so nothing is claimed about it. */ + @ParameterizedTest + @ValueSource(strings = {" env_file: .env\n", " env_file:\n - .env\n - .env.local\n"}) + void anEnvFileMakesTheStorageModeUnknown(String envFile) throws Exception { + ComposeCheck.Report r = aws(service("\"4566:4566\"", " - ./state:/app/data\n" + envFile)); + + assertEquals(List.of(), r.warnings(), envFile); + } + + /** A mode the file itself spells out is still judged, env_file or not. */ + @Test + void anExplicitStorageModeIsJudgedEvenWithAnEnvFile() throws Exception { + ComposeCheck.Report r = aws(service("\"4566:4566\"", + " - ./state:/app/data\n env_file: .env\n environment: {FLOCI_STORAGE_MODE: memory}\n")); + + assertEquals(1, r.warnings().size(), r.warnings().toString()); + } + + @Test + void persistentStorageWithoutADataVolumeIsFlagged() throws Exception { + ComposeCheck.Report r = aws(service("\"4566:4566\"", " environment:\n FLOCI_STORAGE_MODE: persistent\n")); + + assertEquals(1, r.warnings().size(), r.warnings().toString()); + assertTrue(r.warnings().get(0).contains("nothing is mounted at /app/data"), r.warnings().get(0)); + } + + @Test + void theStorageVariableIsTheProductsOwn() throws Exception { + JsonNode compose = YAML.readTree(""" + services: + oci: + image: floci/floci-oci:latest + ports: ["4599:4599"] + volumes: ["./state:/app/data", "/var/run/docker.sock:/var/run/docker.sock"] + environment: + FLOCI_STORAGE_MODE: persistent + """); + + ComposeCheck.Report r = ComposeCheck.analyze(compose, ProductProfile.OCI, true, "Functions", tempDir); + + assertTrue(r.warnings().get(0).contains("FLOCI_OCI_STORAGE_MODE is not 'persistent'"), r.warnings().toString()); + } + + @ParameterizedTest + @ValueSource(strings = {" - ./data:/app/data:ro\n", " - floci-data:/app/data/:ro,z\n", + " - {type: bind, source: ./data, target: /app/data, read_only: true}\n"}) + void aReadOnlyDataVolumeIsAnError(String volume) throws Exception { + ComposeCheck.Report r = aws(service("\"4566:4566\"", volume + " environment: {FLOCI_STORAGE_MODE: persistent}\n")); + + assertEquals(1, r.errors().size(), r.errors().toString()); + assertTrue(r.errors().get(0).contains("mounted read-only"), r.errors().get(0)); + } + + @Test + void aDataVolumeBoundToAFileIsAnError() throws Exception { + Files.writeString(tempDir.resolve("data"), "not a directory"); + + ComposeCheck.Report r = aws(service("\"4566:4566\"", + " - ./data:/app/data\n environment: {FLOCI_STORAGE_MODE: persistent}\n")); + + assertEquals(1, r.errors().size(), r.errors().toString()); + assertTrue(r.errors().get(0).contains("which is a file, not a directory"), r.errors().get(0)); + } + + /** In the long form the type says the source is a host path, even when it is a bare name. */ + @Test + void aLongFormBindToAFileIsAnErrorEvenWithABareName() throws Exception { + Files.writeString(tempDir.resolve("data"), "not a directory"); + + ComposeCheck.Report bind = aws(service("\"4566:4566\"", + " - {type: bind, source: data, target: /app/data}\n environment: {FLOCI_STORAGE_MODE: persistent}\n")); + ComposeCheck.Report named = aws(service("\"4566:4566\"", + " - {type: volume, source: data, target: /app/data}\n environment: {FLOCI_STORAGE_MODE: persistent}\n")); + ComposeCheck.Report shortNamed = aws(service("\"4566:4566\"", + " - data:/app/data\n environment: {FLOCI_STORAGE_MODE: persistent}\n")); + + assertEquals(1, bind.errors().size(), bind.errors().toString()); + assertTrue(bind.errors().get(0).contains("which is a file, not a directory"), bind.errors().get(0)); + assertEquals(List.of(), named.errors(), "a named volume called 'data' is not the file"); + assertEquals(List.of(), shortNamed.errors(), "nor is the short form's bare name"); + } + + /** A directory, a path that does not exist yet and a named volume say nothing against the mount. */ + @ParameterizedTest + @ValueSource(strings = {"./state", "./not-there-yet", "floci-data", "${DATA_DIR}"}) + void otherDataSourcesAreNotJudged(String source) throws Exception { + Files.createDirectories(tempDir.resolve("state")); + + ComposeCheck.Report r = aws(service("\"4566:4566\"", + " - " + source + ":/app/data\n environment: {FLOCI_STORAGE_MODE: persistent}\n")); + + assertEquals(List.of(), r.errors(), source); + } + + // ---- image --------------------------------------------------------------------------------- + + @Test + void anImageOlderThanTheSupportedMinimumIsFlagged() throws Exception { + ComposeCheck.Report r = aws(service("\"4566:4566\"", "").replace("floci/floci:latest", "floci/floci:1.4.2")); + + assertTrue(r.valid()); + assertEquals(1, r.warnings().size(), r.warnings().toString()); + assertTrue(r.warnings().get(0).contains("Image tag 1.4.2 is older than 1.5.0"), r.warnings().get(0)); + } + + @ParameterizedTest + @ValueSource(strings = {"floci/floci", "floci/floci:latest", "floci/floci:1.5.0", "floci/floci:2.0.1", + "ghcr.io/floci-io/floci:1.6.0", "docker.io/floci/floci:1.6.0", "floci/floci:1.6.0@sha256:abc", "floci/floci:nightly"}) + void supportedOrUnversionedImagesAreNotFlagged(String image) throws Exception { + ComposeCheck.Report r = aws(service("\"4566:4566\"", "").replace("floci/floci:latest", image)); + + assertEquals("floci", r.service(), image); + assertEquals(List.of(), r.warnings(), image); + } + + @Test + void repositoriesAndTagsAreSplitAtTheRightColon() { + assertEquals("registry.local:5000/floci/floci", ComposeCheck.repositoryOf("registry.local:5000/floci/floci:1.6.0")); + assertEquals("1.6.0", ComposeCheck.tagOf("registry.local:5000/floci/floci:1.6.0")); + assertEquals("registry.local:5000/floci/floci", ComposeCheck.repositoryOf("registry.local:5000/floci/floci")); + assertEquals("", ComposeCheck.tagOf("registry.local:5000/floci/floci")); + } + + /** One service and no recognisable image (built locally, mirrored): it is still the one to check. */ + @Test + void aSingleServiceIsCheckedEvenWithoutARecognisedImage() throws Exception { + ComposeCheck.Report r = aws(""" + services: + emulator: + build: . + """); + + assertEquals("emulator", r.service()); + assertEquals(2, r.errors().size(), r.errors().toString()); + assertTrue(r.warnings().get(0).contains("image reference not detected"), r.warnings().toString()); + } + + /** Several services and none recognisable: checking one at random would only mislead. */ + @Test + void severalServicesWithoutARecognisedImageAreNotGuessedAt() throws Exception { + ComposeCheck.Report r = aws(""" + services: + web: {image: nginx} + db: {image: postgres} + """); + + assertNull(r.service()); + assertEquals(List.of(), r.errors()); + assertEquals(1, r.warnings().size()); + } + + @Test + void aFileWithoutServicesIsAnError() throws Exception { + ComposeCheck.Report r = aws("version: '3'\n"); + + assertFalse(r.valid()); + assertTrue(r.errors().get(0).startsWith("No services found"), r.errors().toString()); + } + + // ---- the command --------------------------------------------------------------------------- + + private record Run(int exit, String out, String err) {} + + private Run run(String... args) { + PrintStream out = System.out; + PrintStream err = System.err; + ByteArrayOutputStream outBuf = new ByteArrayOutputStream(); + ByteArrayOutputStream errBuf = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outBuf)); + System.setErr(new PrintStream(errBuf)); + try { + int exit = FlociCli.buildCommandLine(new ProfileStore(tempDir.resolve("profiles"))).execute(args); + return new Run(exit, outBuf.toString(), errBuf.toString()); + } finally { + System.setOut(out); + System.setErr(err); + } + } + + @Test + void jsonOutputCarriesTheFindingsAndTheExitCode() throws Exception { + Path file = Files.writeString(tempDir.resolve("compose.yml"), """ + services: + floci: + image: floci/floci:1.4.0 + ports: ["4566:8080"] + volumes: ["/var/run/docker.sock:/var/run/docker.sock"] + """); + + Run r = run("config", "validate", "-f", file.toString(), "-o", "json"); + + assertEquals(1, r.exit()); + JsonNode json = new ObjectMapper().readTree(r.out()); + assertEquals(file.toString(), json.path("file").asText()); + assertEquals("floci", json.path("service").asText()); + assertFalse(json.path("valid").asBoolean()); + assertEquals(1, json.path("errors").size()); + assertEquals(1, json.path("warnings").size()); + assertFalse(r.out().contains("Validating"), "no text banner in structured output"); + } + + @Test + void aValidFileExitsZeroInEveryTree() throws Exception { + Path file = Files.writeString(tempDir.resolve("compose.yml"), """ + services: + gcp: + image: floci/floci-gcp:latest + ports: ["14588:4588"] + volumes: ["/var/run/docker.sock:/var/run/docker.sock"] + """); + + Run text = run("gcp", "config", "validate", "-f", file.toString()); + Run yaml = run("gcp", "config", "validate", "-f", file.toString(), "-o", "yaml"); + + assertEquals(0, text.exit(), text.out() + text.err()); + assertTrue(text.out().contains("Compose file looks good"), text.out()); + assertEquals(0, yaml.exit()); + assertTrue(yaml.out().contains("valid: true"), yaml.out()); + } + + @Test + void aFileThatIsNotYamlIsReportedWithANextStep() throws Exception { + Path file = Files.writeString(tempDir.resolve("compose.yml"), "services: [unterminated\n"); + + Run r = run("config", "validate", "-f", file.toString()); + + assertEquals(1, r.exit()); + assertTrue(r.err().contains("as YAML"), r.err()); + assertTrue(r.err().contains("pass another with --file"), r.err()); + } + + /** A script reading the report gets one for a file that cannot be parsed too. */ + @ParameterizedTest + @ValueSource(strings = {"services: [unterminated\n", "- just\n- a list\n", "plain text\n"}) + void aFileThatCannotBeReadStillGetsAStructuredReport(String content) throws Exception { + Path file = Files.writeString(tempDir.resolve("compose.yml"), content); + + Run r = run("config", "validate", "-f", file.toString(), "-o", "json"); + + assertEquals(1, r.exit()); + JsonNode json = new ObjectMapper().readTree(r.out()); + assertEquals(file.toString(), json.path("file").asText()); + assertTrue(json.path("service").isNull(), r.out()); + assertFalse(json.path("valid").asBoolean()); + assertEquals(1, json.path("errors").size()); + assertTrue(json.path("errors").get(0).asText().startsWith("Could not read "), r.out()); + assertEquals(0, json.path("warnings").size()); + assertEquals("", r.err()); + } +} diff --git a/src/test/java/io/floci/cli/unit/DockerClientProcessTest.java b/src/test/java/io/floci/cli/unit/DockerClientProcessTest.java index fb5d9a9..2dea2c7 100644 --- a/src/test/java/io/floci/cli/unit/DockerClientProcessTest.java +++ b/src/test/java/io/floci/cli/unit/DockerClientProcessTest.java @@ -1,5 +1,7 @@ package io.floci.cli.unit; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import io.floci.cli.GlobalOptions; import io.floci.cli.docker.DockerClient; import io.floci.cli.docker.DockerException; @@ -271,4 +273,74 @@ class DockerClientProcessTest { assertTrue(errBuf.toString().contains("+ docker rm"), errBuf.toString()); assertTrue(errBuf.toString().contains("floci-x"), errBuf.toString()); } + + private DockerClient dockerPrinting(String inspectJson) throws Exception { + Path json = Files.createTempFile(tempDir, "inspect", ".json"); + Files.writeString(json, inspectJson); + Path fakeDocker = Files.createTempFile(tempDir, "docker", ""); + Files.writeString(fakeDocker, "#!/bin/sh\ncat '" + json + "'\n"); + assertTrue(fakeDocker.toFile().setExecutable(true)); + return new DockerClient(fakeDocker.toString()); + } + + /** BL-046: container details come from the inspect document, not from a delimiter-split template. */ + @Test + @DisabledOnOs(OS.WINDOWS) + void containerDetailsAreReadFromTheInspectDocument() throws Exception { + DockerClient docker = dockerPrinting(""" + {"Id":"0123abcd","Name":"/floci-team-b","Config":{"Image":"floci/floci:1.6.0"}, + "State":{"Status":"running"}, + "NetworkSettings":{"Ports":{"4566/tcp":[{"HostIp":"0.0.0.0","HostPort":"14566"},{"HostIp":"::","HostPort":"14566"}], + "8080/tcp":null}}} + """); + + DockerClient.ContainerInfo info = docker.inspectContainer("floci-team-b").orElseThrow(); + + assertEquals("0123abcd", info.id()); + assertEquals("floci-team-b", info.name()); + assertEquals("floci/floci:1.6.0", info.image()); + assertEquals("running", info.state()); + assertEquals("14566->4566/tcp", info.ports()); + } + + /** A value with the old delimiter in it cannot shift the fields any more. */ + @Test + @DisabledOnOs(OS.WINDOWS) + void aPipeInAValueDoesNotShiftTheFields() throws Exception { + DockerClient docker = dockerPrinting(""" + {"Id":"0123abcd","Name":"/floci","Config":{"Image":"registry.local/team|floci:latest"}, + "State":{"Status":"exited"},"NetworkSettings":{"Ports":{}}} + """); + + DockerClient.ContainerInfo info = docker.inspectContainer("floci").orElseThrow(); + + assertEquals("registry.local/team|floci:latest", info.image()); + assertEquals("exited", info.state()); + assertEquals("", info.ports()); + } + + @Test + void publishedPortsListEveryBindingAndSkipWhatIsNotPublished() throws Exception { + JsonNode ports = new ObjectMapper().readTree(""" + {"4566/tcp":[{"HostIp":"","HostPort":"14566"}],"8080/tcp":null,"9000/tcp":[], + "4510/tcp":[{"HostIp":"","HostPort":"24510"}]} + """); + + assertEquals("14566->4566/tcp 24510->4510/tcp", DockerClient.publishedPorts(ports)); + assertEquals("", DockerClient.publishedPorts(new ObjectMapper().readTree("{}"))); + } + + @Test + @DisabledOnOs(OS.WINDOWS) + void aMissingContainerIsEmptyAndGarbageIsReportedWithANextStep() throws Exception { + Path missing = Files.createTempFile(tempDir, "docker", ""); + Files.writeString(missing, "#!/bin/sh\necho 'Error response from daemon: No such container: floci' >&2\nexit 1\n"); + assertTrue(missing.toFile().setExecutable(true)); + + assertTrue(new DockerClient(missing.toString()).inspectContainer("floci").isEmpty()); + + DockerException e = assertThrows(DockerException.class, () -> dockerPrinting("not json").inspectContainer("floci")); + assertTrue(e.getMessage().contains("Could not read the details of container 'floci'"), e.getMessage()); + assertTrue(e.getMessage().contains("docker info"), e.getMessage()); + } } diff --git a/src/test/java/io/floci/cli/unit/ErgonomicsTest.java b/src/test/java/io/floci/cli/unit/ErgonomicsTest.java new file mode 100644 index 0000000..66b4da7 --- /dev/null +++ b/src/test/java/io/floci/cli/unit/ErgonomicsTest.java @@ -0,0 +1,372 @@ +package io.floci.cli.unit; + +import com.sun.net.httpserver.HttpServer; +import io.floci.cli.FlociCli; +import io.floci.cli.GlobalOptions; +import io.floci.cli.ProductProfile; +import io.floci.cli.ServerCompatibility; +import io.floci.cli.commands.config.ConfigProfileCommand; +import io.floci.cli.config.Profile; +import io.floci.cli.config.ProfileStore; +import io.floci.cli.output.Glyphs; +import io.floci.cli.output.OutputFormat; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledOnOs; +import org.junit.jupiter.api.condition.OS; +import org.junit.jupiter.api.io.TempDir; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; +import org.junit.jupiter.params.provider.ValueSource; +import picocli.CommandLine; +import picocli.CommandLine.ParseResult; + +import java.io.ByteArrayOutputStream; +import java.io.OutputStream; +import java.io.PrintStream; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.Map; +import java.util.function.IntSupplier; + +import static org.junit.jupiter.api.Assertions.*; + +/** BL-059 to BL-062: --json, plain marks, config profile edit and the old-server warning. */ +class ErgonomicsTest { + + @TempDir + Path tempDir; + + private record Run(int exit, String out, String err) {} + + private static Run capture(IntSupplier body) { + PrintStream out = System.out; + PrintStream err = System.err; + ByteArrayOutputStream outBuf = new ByteArrayOutputStream(); + ByteArrayOutputStream errBuf = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outBuf)); + System.setErr(new PrintStream(errBuf)); + try { + int exit = body.getAsInt(); + return new Run(exit, outBuf.toString(), errBuf.toString()); + } finally { + System.setOut(out); + System.setErr(err); + } + } + + private Run run(String... args) { + return capture(() -> FlociCli.buildCommandLine(new ProfileStore(tempDir.resolve("profiles"))).execute(args)); + } + + // ---- --json ------------------------------------------------------------------------------------ + + @ParameterizedTest + @CsvSource({"'status --json', json", "'status -o yaml', yaml", "'status', text", "'status --json -o yaml', json", + "'gcp doctor --json', json", "'oci services --json', json"}) + void jsonIsShorthandForOutputJson(String commandLine, OutputFormat expected) { + ParseResult r = FlociCli.buildCommandLine(new ProfileStore(tempDir)).parseArgs(commandLine.split(" ")); + while (r.hasSubcommand()) r = r.subcommand(); + GlobalOptions global = (GlobalOptions) r.commandSpec().mixins().values().stream() + .map(m -> m.userObject()).filter(GlobalOptions.class::isInstance).findFirst().orElseThrow(); + + assertEquals(expected, global.format()); + } + + @Test + void jsonReachesTheCommandsOutput() throws Exception { + Files.createDirectories(tempDir.resolve("profiles")); + Files.writeString(tempDir.resolve("profiles").resolve("one.yaml"), "port: 4599\n"); + + Run r = run("config", "profile", "list", "--json"); + + assertEquals(0, r.exit(), r.err()); + assertTrue(r.out().strip().startsWith("[") || r.out().strip().startsWith("{"), r.out()); + } + + // ---- marks ------------------------------------------------------------------------------------- + + @ParameterizedTest + @CsvSource({"false, true, false, false", "true, true, false, true", "false, false, false, true", "false, true, true, true"}) + void marksArePlainOnRequestInAPipeAndUnderNoColor(boolean noEmoji, boolean terminal, boolean noColorEnv, boolean plain) { + assertEquals(plain, GlobalOptions.plainGlyphs(noEmoji, terminal, noColorEnv)); + } + + /** The update notice is printed before any command runs, so the choice is made from the raw arguments too. */ + @ParameterizedTest + @CsvSource({"'status --no-emoji', false, true, true", "'status', false, true, false", "'status', true, true, true", + "'status', false, false, true", "'--no-emoji=true status', false, true, true"}) + void theMarksAreChosenBeforeAnyCommandRuns(String commandLine, boolean noColorEnv, boolean interactive, boolean plain) { + assertEquals(plain, FlociCli.plainGlyphs(commandLine.split(" "), noColorEnv, interactive)); + } + + @Test + void thePlainSetIsAsciiOnly() { + for (String mark : List.of(Glyphs.ASCII.ok(), Glyphs.ASCII.warn(), Glyphs.ASCII.fail(), Glyphs.ASCII.arrow())) { + assertTrue(mark.chars().allMatch(c -> c < 128), mark); + } + assertEquals("✓", Glyphs.UNICODE.ok()); + } + + /** A test run is not a terminal, so a command's output here carries the plain marks. */ + @Test + void pipedOutputCarriesNoUnicodeMarks() throws Exception { + Path compose = Files.writeString(tempDir.resolve("compose.yml"), """ + services: + floci: + image: floci/floci:latest + ports: ["4566:4566"] + volumes: ["/var/run/docker.sock:/var/run/docker.sock"] + """); + + Run r = run("config", "validate", "-f", compose.toString(), "--no-emoji"); + + assertEquals(0, r.exit(), r.out() + r.err()); + assertTrue(Glyphs.isPlain()); + assertTrue(r.out().contains(Glyphs.ASCII.ok() + " Compose file looks good"), r.out()); + assertFalse(r.out().contains("✓"), r.out()); + } + + // ---- config profile edit ----------------------------------------------------------------------- + + private ProfileStore store() { + return new ProfileStore(tempDir.resolve("profiles")); + } + + private Path editorThat(String body) throws Exception { + Path editor = Files.createTempFile(tempDir, "editor", ".sh"); + Files.writeString(editor, "#!/bin/sh\n" + body + "\n"); + assertTrue(editor.toFile().setExecutable(true)); + return editor; + } + + private Run edit(Map env, String name) { + ConfigProfileCommand command = new ConfigProfileCommand(ProductProfile.AWS, store(), env::get); + return capture(() -> new CommandLine(command).execute("edit", name)); + } + + @Test + @DisabledOnOs(OS.WINDOWS) + void editOpensTheProfilesFileAndKeepsTheChange() throws Exception { + store().save(new Profile(ProductProfile.AWS, "dev")); + Path editor = editorThat("echo 'port: 14566' >> \"$1\""); + + Run r = edit(Map.of("EDITOR", editor.toString()), "dev"); + + assertEquals(0, r.exit(), r.err()); + assertEquals(14566, store().get("dev").orElseThrow().port); + assertTrue(r.out().contains("Profile 'dev' saved"), r.out()); + } + + /** VISUAL wins over EDITOR, and a value with arguments is a command line. */ + @Test + @DisabledOnOs(OS.WINDOWS) + void visualWinsAndArgumentsArePassedOn() throws Exception { + store().save(new Profile(ProductProfile.AWS, "dev")); + Path args = tempDir.resolve("args"); + Path visual = editorThat("echo \"$1 $2\" > '" + args + "'"); + Path editor = editorThat("exit 9"); + + Run r = edit(Map.of("VISUAL", visual + " --wait", "EDITOR", editor.toString()), "dev"); + + assertEquals(0, r.exit(), r.err()); + assertEquals("--wait " + store().existingFile("dev"), Files.readString(args).strip()); + } + + /** A quoted path with spaces is one word, as a shell would read it; nothing else is interpreted. */ + @ParameterizedTest + @CsvSource(delimiter = '|', quoteCharacter = '`', value = { + "\"/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code\" --wait | /Applications/Visual Studio Code.app/Contents/Resources/app/bin/code;--wait", + "'/opt/my editor/bin/edit' -n | /opt/my editor/bin/edit;-n", + "/opt/my\\ editor/bin/edit | /opt/my editor/bin/edit", + "emacsclient -c -a \"emacs --no-splash\" | emacsclient;-c;-a;emacs --no-splash", + "vim -c 'set ft=yaml' | vim;-c;set ft=yaml", + "code --wait | code;--wait", + "nano --rcfile=\"my rc\" | nano;--rcfile=my rc", + "echo \"a \\\"quoted\\\" word\" | echo;a \"quoted\" word", + "C:\\Windows\\System32\\notepad.exe | C:\\Windows\\System32\\notepad.exe", + "\"C:\\Program Files\\Microsoft VS Code\\bin\\code.cmd\" --wait | C:\\Program Files\\Microsoft VS Code\\bin\\code.cmd;--wait", + "\\\\tools\\share\\edit.exe -n | \\\\tools\\share\\edit.exe;-n", + "'C:\\my tools\\edit.exe' | C:\\my tools\\edit.exe", + "ed '' | ed;"}) + void anEditorValueIsSplitLikeAShellWould(String value, String expected) { + assertEquals(List.of(expected.split(";", -1)), ConfigProfileCommand.editorCommand(value, null)); + } + + @Test + @DisabledOnOs(OS.WINDOWS) + void anEditorInADirectoryWithSpacesIsRun() throws Exception { + store().save(new Profile(ProductProfile.AWS, "dev")); + Path dir = Files.createDirectories(tempDir.resolve("my editors")); + Path editor = Files.writeString(dir.resolve("edit it"), "#!/bin/sh\necho 'port: 14566' >> \"$2\"\n"); + assertTrue(editor.toFile().setExecutable(true)); + + Run r = edit(Map.of("EDITOR", "\"" + editor + "\" --wait"), "dev"); + + assertEquals(0, r.exit(), r.err()); + assertEquals(14566, store().get("dev").orElseThrow().port); + } + + @Test + void theEditorIsVisualThenEditorSplitOnSpaces() { + assertEquals(List.of("code", "--wait"), ConfigProfileCommand.editorCommand("code --wait", "vi")); + assertEquals(List.of("vi"), ConfigProfileCommand.editorCommand(null, "vi")); + assertEquals(List.of("vi"), ConfigProfileCommand.editorCommand(" ", " vi ")); + assertEquals(List.of(), ConfigProfileCommand.editorCommand(null, null)); + assertEquals(List.of(), ConfigProfileCommand.editorCommand("", "")); + } + + @Test + void editWithoutAnEditorSaysHowToSetOne() throws Exception { + store().save(new Profile(ProductProfile.AWS, "dev")); + + Run r = edit(Map.of(), "dev"); + + assertEquals(1, r.exit()); + assertTrue(r.err().contains("No editor is set"), r.err()); + assertTrue(r.err().contains("export EDITOR="), r.err()); + } + + @Test + void editingAProfileThatDoesNotExistPointsAtCreate() { + Run r = edit(Map.of("EDITOR", "true"), "nope"); + + assertEquals(1, r.exit()); + assertTrue(r.err().contains("Profile 'nope' not found."), r.err()); + assertTrue(r.err().contains("floci config profile create nope"), r.err()); + } + + @Test + @DisabledOnOs(OS.WINDOWS) + void anEditThatBreaksTheFileIsReportedAtOnce() throws Exception { + store().save(new Profile(ProductProfile.AWS, "dev")); + Path editor = editorThat("echo 'port: [unterminated' > \"$1\""); + + Run r = edit(Map.of("EDITOR", editor.toString()), "dev"); + + assertEquals(1, r.exit()); + assertTrue(r.err().contains("Profile 'dev' is no longer valid"), r.err()); + assertTrue(r.err().contains("floci config profile edit dev"), r.err()); + } + + /** A profile that does not parse, or holds YAML's "nothing", can still be opened and repaired. */ + @ParameterizedTest + @ValueSource(strings = {"port: [unterminated\n", "null\n", "~\n", "- a list\n"}) + @DisabledOnOs(OS.WINDOWS) + void aBrokenProfileCanBeOpenedAndRepaired(String broken) throws Exception { + Path file = Files.createDirectories(tempDir.resolve("profiles")).resolve("dev.yaml"); + Files.writeString(file, broken); + Path editor = editorThat("echo 'port: 14566' > \"$1\""); + + Run r = edit(Map.of("EDITOR", editor.toString()), "dev"); + + assertEquals(0, r.exit(), r.err()); + assertEquals(14566, store().get("dev").orElseThrow().port); + } + + /** Saving YAML's "nothing" is reported like any other file that is no longer a profile. */ + @ParameterizedTest + @ValueSource(strings = {"null", "~"}) + @DisabledOnOs(OS.WINDOWS) + void anEditThatLeavesNothingIsReported(String nothing) throws Exception { + store().save(new Profile(ProductProfile.AWS, "dev")); + Path editor = editorThat("echo '" + nothing + "' > \"$1\""); + + Run r = edit(Map.of("EDITOR", editor.toString()), "dev"); + + assertEquals(1, r.exit()); + assertTrue(r.err().contains("Profile 'dev' is no longer valid"), r.err()); + assertTrue(r.err().contains("holds no settings"), r.err()); + assertFalse(r.err().contains("Exception"), r.err()); + } + + @Test + @DisabledOnOs(OS.WINDOWS) + void anEditorThatFailsIsReported() throws Exception { + store().save(new Profile(ProductProfile.AWS, "dev")); + + Run failed = edit(Map.of("EDITOR", editorThat("exit 3").toString()), "dev"); + Run missing = edit(Map.of("EDITOR", tempDir.resolve("no-such-editor").toString()), "dev"); + + assertEquals(1, failed.exit()); + assertTrue(failed.err().contains("exited with code 3"), failed.err()); + assertEquals(1, missing.exit()); + assertTrue(missing.err().contains("Could not start the editor"), missing.err()); + assertTrue(missing.err().contains("Set EDITOR to a command on your PATH"), missing.err()); + } + + // ---- the old-server warning -------------------------------------------------------------------- + + @ParameterizedTest + @ValueSource(strings = {"1.4.9", "1.0.0", "0.9.0"}) + void anAwsServerBelowTheMinimumIsWarnedAbout(String version) { + String warning = ServerCompatibility.warning(ProductProfile.AWS, version, "").orElseThrow(); + + assertTrue(warning.contains("server " + version + " is older than 1.5.0"), warning); + assertTrue(warning.contains("docker pull floci/floci:latest"), warning); + assertTrue(warning.contains("then run 'floci restart'."), warning); + } + + @ParameterizedTest + @ValueSource(strings = {"1.5.0", "2.2.0", "unknown", "unavailable", "", "dev-SNAPSHOT"}) + void aSupportedOrUnreadableVersionIsNotWarnedAbout(String version) { + assertTrue(ServerCompatibility.warning(ProductProfile.AWS, version, "").isEmpty(), version); + } + + /** The other emulators are on 0.x version lines of their own: the AWS minimum says nothing about them. */ + @Test + void theOtherProductsHaveNoMinimum() { + for (ProductProfile product : List.of(ProductProfile.GCP, ProductProfile.AZ, ProductProfile.OCI)) { + assertTrue(ServerCompatibility.warning(product, "0.4.2", "").isEmpty(), product.name()); + } + assertTrue(ServerCompatibility.warning(ProductProfile.AWS, null, "").isEmpty()); + } + + /** The hint acts on the instance the version came from, and keeps that instance's settings. */ + @Test + void theHintSelectsTheSameInstance() { + String warning = ServerCompatibility.warning(ProductProfile.AWS, "1.4.0", " --profile dev").orElseThrow(); + + assertTrue(warning.contains("then run 'floci restart --profile dev'."), warning); + // The way out for a pinned tag acts on the same instance too. + assertTrue(warning.contains("floci stop --remove --profile dev"), warning); + } + + /** restart keeps the image reference, so the hint says what to do when that reference is the old tag. */ + @Test + void theHintCoversAnInstancePinnedToAnOldTag() { + String warning = ServerCompatibility.warning(ProductProfile.AWS, "1.4.0", " --container dev").orElseThrow(); + + assertTrue(warning.contains("If the instance pins an older tag, restart keeps it"), warning); + assertTrue(warning.contains("change 'image' in its profile"), warning); + assertTrue(warning.contains("'--image floci/floci:latest'"), warning); + } + + @Test + void statusWarnsOnStderrAndKeepsStdoutOneDocument() throws Exception { + HttpServer server = HttpServer.create(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0); + server.createContext("/", exchange -> { + byte[] body = "{\"version\":\"1.4.0\",\"edition\":\"community\",\"services\":[]}".getBytes(StandardCharsets.UTF_8); + exchange.sendResponseHeaders(200, body.length); + try (OutputStream out = exchange.getResponseBody()) { + out.write(body); + } + exchange.close(); + }); + server.start(); + try { + Run r = run("status", "--json", "--container", "floci-ergonomics-none", + "--endpoint", "http://127.0.0.1:" + server.getAddress().getPort()); + + assertTrue(r.err().contains("server 1.4.0 is older than 1.5.0"), r.err()); + assertTrue(r.err().contains("floci restart --container floci-ergonomics-none"), r.err()); + assertTrue(r.out().strip().startsWith("{") && r.out().strip().endsWith("}"), r.out()); + assertFalse(r.out().contains("older than"), r.out()); + } finally { + server.stop(0); + } + } +} diff --git a/src/test/java/io/floci/cli/unit/ExitCodeTableTest.java b/src/test/java/io/floci/cli/unit/ExitCodeTableTest.java index caefa20..8fd74a6 100644 --- a/src/test/java/io/floci/cli/unit/ExitCodeTableTest.java +++ b/src/test/java/io/floci/cli/unit/ExitCodeTableTest.java @@ -36,11 +36,15 @@ class ExitCodeTableTest { "2, start --pull sometimes", "2, doctor --check no.such.check", "2, env --shell tcsh", + "2, completion fish", + "2, status --json --no-such-flag", "2, config profile show ../escape", // Accepted by the command line, rejected by the command with 1. "1, update --version not-a-version", "1, config profile create demo --port 0", "1, config profile show no-such-profile", + "1, config profile edit no-such-profile", + "1, config validate -f no-such-compose-file.yml", // Nothing wrong. "0, --version", "0, config profile list"}) diff --git a/src/test/java/io/floci/cli/unit/StartPreflightTest.java b/src/test/java/io/floci/cli/unit/StartPreflightTest.java index 0930b69..0e8fd82 100644 --- a/src/test/java/io/floci/cli/unit/StartPreflightTest.java +++ b/src/test/java/io/floci/cli/unit/StartPreflightTest.java @@ -60,6 +60,11 @@ class StartPreflightTest { calls.add("pull"); } + @Override + public void pull(String image, String policy, PrintStream progress) { + calls.add("pull"); + } + @Override public String startContainer(List args) { runArgs.addAll(args);