Skip to content

status: add support for multiple output formats#1249

Open
psergee wants to merge 1 commit intotarantool:masterfrom
psergee:feat/status-format-support
Open

status: add support for multiple output formats#1249
psergee wants to merge 1 commit intotarantool:masterfrom
psergee:feat/status-format-support

Conversation

@psergee
Copy link
Contributor

@psergee psergee commented Mar 2, 2026

The status command now supports JSON and YAML output formats in addition to the existing table format. This change introduces a printer interface that separates output formatting logic from core status functionality.

New --format CLI option allows users to get machine-readable output for automation purposes.

Closes #1245

@TarantoolBot document
Title: tt status supports JSON and YAML output formats

The tt status command now supports multiple output formats:

  • Table format (default, human-readable)
  • JSON format (machine-readable, for automation)
  • YAML format (machine-readable, for automation)

Usage:

  • tt status - default table output
  • tt status --format=json - JSON output
  • tt status --format=yaml - YAML output

The JSON and YAML formats include all status information:

  • Instance name
  • Status (RUNNING, STOPPED, etc.)
  • PID (if running)
  • Mode (RW/RO)
  • Config status
  • Box status
  • Upstream status
  • Alerts (with severity levels)

Example JSON output:

{
  "app:master": {
    "status": "RUNNING",
    "pid": 12345,
    "mode": "RW",
    "config": "ready",
    "box": "running",
    "upstream": "--",
    "alerts": []
  }
}

@patapenka-alexey patapenka-alexey added the full-ci Enables full ci tests label Mar 3, 2026
@psergee psergee added the feature A new functionality label Mar 3, 2026
Copy link
Contributor

@patapenka-alexey patapenka-alexey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the patch! LGTM.

The status command now supports JSON and YAML output formats in addition
to the existing table format. This change introduces a printer interface
that separates output formatting logic from core status functionality.

New --format CLI option allows users to get machine-readable output for
automation purposes.

Closes tarantool#1245

@TarantoolBot document
Title: `tt status` supports JSON and YAML output formats

The `tt status` command now supports multiple output formats:
- Table format (default, human-readable)
- JSON format (machine-readable, for automation)
- YAML format (machine-readable, for automation)

Usage:
- `tt status` - default table output
- `tt status --format=json` - JSON output
- `tt status --format=yaml` - YAML output

The JSON and YAML formats include all status information:
- Instance name
- Status (RUNNING, STOPPED, etc.)
- PID (if running)
- Mode (RW/RO)
- Config status
- Box status
- Upstream status
- Alerts (with severity levels)

Example JSON output:
```json
{
  "app:master": {
    "status": "RUNNING",
    "pid": 12345,
    "mode": "RW",
    "config": "ready",
    "box": "running",
    "upstream": "--",
    "alerts": []
  }
}
```
@psergee psergee force-pushed the feat/status-format-support branch from 104136a to 24ef0a7 Compare March 10, 2026 19:31
@psergee psergee requested a review from elhimov March 11, 2026 11:22
Copy link
Collaborator

@bigbes bigbes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your patch! Pls consider fixing this minor issues (or questions).

},
}

statusCmd.Flags().BoolVarP(&opts.Pretty, "pretty", "p", false, "pretty-print table")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty flag is removed, but it doesn't documented

Comment on lines +232 to 235
printer.Print(instances)

return nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
printer.Print(instances)
return nil
}
return printer.Print(instances)
}


err = status.Status(runningCtx, opts)
var printer status.InstanceStatusPrinter
switch opts.format {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alerts (details) are always enabled in "json/yaml" printer?

import (
"fmt"

"gopkg.in/yaml.v2"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is new file - let's use yaml.v3 here.

Comment on lines +13 to +14
// StatusOpts contains options for tt status.
type statusOpts struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// StatusOpts contains options for tt status.
type statusOpts struct {
// statusOpts contains options for tt status.
type statusOpts struct {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature A new functionality full-ci Enables full ci tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add the --json or --yaml option to tt status

3 participants