Skip to content

Add CLI --json output flag #409

Description

@Levi-Ojukwu

Description:

The ILN CLI currently only outputs human-readable formatted text. This makes it difficult for scripts, automation tools, and other programs to consume CLI output programmatically. Adding a global --json flag would enable machine-readable output for all commands.

The CLI is built using the commander library in cli/src/index.ts. The program already accepts a --profile global option. The --json flag should follow the same pattern.

When --json is set:

  • All commands output valid JSON to stdout
  • Error messages are structured as { "error": "...", "code": "..." }
  • Success responses include the full data payload
  • No ANSI color codes or formatting

Affected commands (all in cli/src/commands/):

  • status.ts — invoice status queries
  • reputation.ts — reputation lookups
  • submit.ts — invoice submission results
  • fund.ts — funding results
  • cancel.ts — cancellation results
  • marketplace.ts — marketplace queries

Why it matters: JSON output enables CI/CD integration, automated testing, and building higher-level tools on top of the CLI. It's a standard feature for developer tools.

Acceptance Criteria:

  • Add --json global flag to the CLI program in cli/src/index.ts
  • Create a shared formatOutput(data, isJson) utility function
  • Update all commands to use the utility
  • Add tests verifying JSON output format for each command
  • Ensure errors are also output as JSON when the flag is set

Relevant Files: cli/src/index.ts, cli/src/commands/status.ts, cli/src/commands/reputation.ts


Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions