Skip to content

Conversation

DanielHougaard
Copy link
Member

Description 📣

This PR adds standardized output formats for the secrets / folders / dynamic-secrets commands.

Type ✨

  • Bug fix
  • New feature
  • Improvement
  • Breaking change
  • Documentation

@DanielHougaard DanielHougaard self-assigned this Oct 4, 2025
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Summary

This PR implements standardized output formats for the Infisical CLI, adding support for JSON, YAML, and dotenv formats across secrets, folders, and dynamic-secrets commands. The implementation introduces a new `FormatOutput` function in `util/common.go` that provides type-safe, generic formatting capabilities with comprehensive error handling.

The core functionality centers around a new --output flag that allows users to specify their desired output format instead of the default human-readable table format. The implementation uses Go generics to handle different data types while maintaining type safety. A key user experience enhancement is the integration of the Levenshtein distance algorithm to provide "did you mean" suggestions when users mistype format names.

The changes maintain full backward compatibility by only activating formatted output when the --output flag is explicitly specified. Each command type (secrets, folders, dynamic-secrets) structures its data appropriately for the different output formats:

  • JSON/YAML: Structured as arrays of objects with relevant metadata fields
  • Dotenv: Special handling for key-value pairs with configurable attribute mapping
  • Default: Preserves existing visualization functions

The implementation follows a consistent pattern across all affected commands, ensuring a uniform user experience. For dynamic secrets, the existing --plain flag is maintained for backward compatibility but marked for deprecation in favor of the dotenv format.

Important Files Changed

Changed Files
Filename Score Overview
go.mod 5/5 Added Levenshtein distance library dependency for fuzzy matching
go.sum 5/5 Checksums for the new Levenshtein library dependency
packages/util/common.go 4/5 Implemented core FormatOutput function with JSON, YAML, and dotenv support plus error handling
packages/cmd/secrets.go 4/5 Added standardized output formatting to all secrets commands with backward compatibility
packages/cmd/folder.go 4/5 Implemented output format support for folder operations (get, create, delete)
packages/cmd/dynamic_secrets.go 4/5 Added output formatting to dynamic secret commands while maintaining plain flag compatibility

Confidence score: 4/5

  • This PR is safe to merge with minimal risk of production issues
  • Score reflects well-structured implementation with proper error handling and backward compatibility
  • Pay close attention to the telemetry placement issue in packages/cmd/secrets.go around line 317

Additional Comments (3)

  1. packages/cmd/dynamic_secrets.go, line 425-427 (link)

    logic: Dead code - error handling block that will never be reached since there's no operation above that could fail

  2. packages/cmd/dynamic_secrets.go, line 555-557 (link)

    logic: Dead code - error handling block that will never be reached since there's no operation above that could fail

  3. packages/cmd/folder.go, line 137-139 (link)

    logic: Dead code - this error check is unreachable since there's no error assigned to err on the previous lines

6 files reviewed, 6 comments

Edit Code Review Agent Settings | Greptile

@DanielHougaard DanielHougaard merged commit 136dedf into main Oct 9, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants