feat: add --format json support to apps:list

The `apps:list` command now accepts a `--format` flag that defaults to `stdout` and can be set to `json` to emit the app names as a JSON array, matching the JSON output the `:report` subcommands already provide. When no apps exist, the JSON output is an empty array.
This commit is contained in:
Jose Diaz-Gonzalez
2026-07-06 11:50:56 -04:00
parent ce69ca76ad
commit 21c27e99cc
5 changed files with 67 additions and 6 deletions

View File

@@ -50,6 +50,36 @@ teardown() {
assert_success
}
@test "(apps) apps:list --format json" {
run /bin/bash -c "dokku apps:list --format json"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "[]"
run /bin/bash -c "dokku apps:create $TEST_APP"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku apps:list --format json | jq '. | length'"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "1"
run /bin/bash -c "dokku apps:list --format json | jq -r '.[0]'"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "$TEST_APP"
run /bin/bash -c "dokku --force apps:destroy $TEST_APP"
echo "output: $output"
echo "status: $status"
assert_success
}
@test "(apps) apps:create" {
run /bin/bash -c "dokku apps:create $TEST_APP"
echo "output: $output"