feat: add --latest flag to ecctl stack list
- Dominant language
- Go
- Stars
- 58
- Forks
- 61
- PR merge metrics
- No merged PRs in 30d
Description
## Summary
Add a `--latest` flag to `ecctl stack list` that returns only the latest stable stack version for a given region, instead of the full list of all available versions.
## Motivation
When creating deployments programmatically, a common need is to resolve the latest available stack version to pass to `ecctl deployment create --version`. Currently this requires fetching the entire stack list (279+ entries) and parsing the output to extract the first item:
```bash
ecctl stack list --region gcp-us-central1 --output json | \
python3 -c "import sys,json; print(json.load(sys.stdin)['stacks'][0]['version'])"
```
A dedicated flag would simplify this to:
```bash
ecctl stack list --region gcp-us-central1 --latest
```
## Proposed behavior
- `ecctl stack list --latest` returns only the latest stable (non-deleted, non-snapshot) stack version.
- Works with `--region` to scope to a specific region.
- Works with `--output json` to return a structured response (e.g. `{"version": "9.3.1"}`).
- Text output simply prints the version string (e.g. `9.3.1`).
## Use case
This came up while building agent skills for automating Elastic Cloud deployment creation. The `ecctl deployment create` command can fail with `"failed to parse version: Version string empty"` if no `--version` is provided and the version can't be inferred, making it important to resolve the latest version explicitly.
Contributor guide
Assessment
This issue has not been assessed yet.