-
Notifications
You must be signed in to change notification settings - Fork 5
feat: standardized output formats #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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)
-
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
-
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
-
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
Description 📣
This PR adds standardized output formats for the
secrets / folders / dynamic-secrets
commands.Type ✨