Skip to content

Standardize output format options across all CLI commands #252

@v0lkan

Description

@v0lkan

Output format options are inconsistent across SPIKE CLI commands. Different commands support different format names, aliases, and some commands ignore the format parameter entirely. All commands that produce output should support a unified set of format options.

Current Behavior

Policy commands:

  • Formats: json, human

Secret commands:

  • Formats: plain, yaml, json, y, p, j

Other commands:

  • Some ignore the --format flag entirely

This inconsistency creates confusion:

  • --format plain works for secrets but not policies
  • --format human works for policies but not secrets
  • --format yaml works for secrets but not policies
  • Some commands silently ignore the format parameter

Proposed Behavior

Standardize on three formats with consistent aliases across ALL commands:

Format Aliases Description
human h, plain, p Human-readable, friendly output (default)
json j Valid JSON output (for scripting/parsing)
yaml y Valid YAML output (for scripting/parsing)

Examples

# All equivalent - human readable
spike secret list --format human
spike secret list --format h
spike secret list --format plain
spike secret list --format p

# All equivalent - JSON
spike policy list --format json
spike policy list --format j

# All equivalent - YAML
spike secret get db/creds --format yaml
spike secret get db/creds --format y

Scope

Every command that produces output (except error messages) should honor the format parameter:

  • spike secret list
  • spike secret get
  • spike secret metadata get
  • spike policy list
  • spike policy get
  • spike operator recover
  • spike operator restore
  • spike cipher encrypt (for metadata output)
  • spike cipher decrypt

Rationale

  1. Consistency: Users should not need to remember which formats work with which commands
  2. Scriptability: Predictable JSON/YAML output enables reliable automation
  3. Discoverability: Fewer format names to document and learn
  4. Backward compatibility: Keeping plain/p as aliases for human/h preserves existing scripts

Implementation Notes

  • Create a shared format parsing function in app/spike/internal/cmd/
  • Default to human when --format is not specified
  • Ensure structured formats (json, yaml) produce valid, parseable output

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions