feat(list): add --json flag to phantom list#48
Open
mvanhorn wants to merge 1 commit intoashlrai:mainfrom
Open
Conversation
Resolves ashlrai#37. Add a `--json` flag to `phantom list` so CI scripts, hooks, and other automation can consume the secret list as structured data instead of parsing the human-readable table. Output shape matches the proposal in the issue: [ { "name": "OPENAI_API_KEY", "detected_service": "openai" }, { "name": "DATABASE_URL", "detected_service": null } ] `detected_service` is the service name from `.phantom.toml` whose `secret_key` matches the secret name, or `null` when no service is configured. Names are emitted in vault order. ## Changes - `crates/phantom-cli/src/main.rs`: change `Commands::List` from a unit variant to `List { json: bool }` and pass the flag through to `commands::list::run`. - `crates/phantom-cli/src/commands/list.rs`: serialise via a private `SecretEntry` struct with `#[derive(Serialize)]` and emit `serde_json::to_string_pretty`. The default human path is unchanged; the JSON path returns early before the human banner so output is pure JSON (safe to pipe to `jq`). - `crates/phantom-cli/Cargo.toml`: add `serde` (workspace) since the command file now `derive(Serialize)`s. `serde_json` was already in the dependency list. - `crates/phantom-cli/tests/list_json_test.rs`: three integration tests covering valid JSON, secret-value safety, and the empty-vault case. ## Verification - `cargo test -p phantom-secrets --test list_json_test`: all 3 pass. - `cargo clippy -p phantom-secrets --all-targets -- -D warnings`: clean. - `cargo fmt --all -- --check`: clean. - The default `phantom list` output is byte-identical to before the change.
|
@mvanhorn is attempting to deploy a commit to the Evero Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #37.
Add a
--jsonflag tophantom listso CI scripts, hooks, and other automation can consume the secret list as structured data instead of grep+awking the human-readable table.Output
[ { "name": "OPENAI_API_KEY", "detected_service": "openai" }, { "name": "DATABASE_URL", "detected_service": null } ]detected_serviceis the service name from.phantom.tomlwhosesecret_keymatches the secret name, ornullwhen no service is configured. Names are emitted in vault order.Changes
crates/phantom-cli/src/main.rs— changeCommands::Listfrom a unit variant toList { json: bool }and pass the flag through tocommands::list::run.crates/phantom-cli/src/commands/list.rs— serialise via a privateSecretEntrystruct with#[derive(Serialize)]and emitserde_json::to_string_pretty. The default human path is unchanged; the JSON path returns early before the human banner so output is pure JSON (safe to pipe tojq).crates/phantom-cli/Cargo.toml— addserde(workspace) since the command file nowderive(Serialize)s.serde_jsonwas already a dependency.crates/phantom-cli/tests/list_json_test.rs— three integration tests:[]Verification
cargo test -p phantom-secrets --test list_json_test: all 3 pass.cargo clippy -p phantom-secrets --all-targets -- -D warnings: clean.cargo fmt --all -- --check: clean.phantom listoutput is byte-identical to before the change.Acceptance criteria
--jsonflag added; existing human output is the defaultserde_json::from_str)crates/phantom-cli/tests/covers the new flag (three actually — happy path, value-leak guard, empty vault)