fix(cli-generator): interpolate env prefix in help; correct README/reference format docs - #17624
Conversation
…ference format and --output docs Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
AI Review Summary
Straightforward docs/help-text fix: env prefix is now interpolated into clap help strings via a new env_var_prefix helper, and generated README/reference tables list the real format values and default. Changes are mirrored consistently into both seed fixtures. Only minor nits below.
- 🔵 2 suggestion(s)
To request another review, comment /ai-review on this pull request.
| pub fn env_var_prefix(binary_name: &str) -> String { | ||
| binary_name.to_uppercase().replace('-', "_") | ||
| } |
There was a problem hiding this comment.
🔵 suggestion
env_var_prefix only handles -; binary names with . or other non-alphanumeric chars (e.g. my.cli) would still produce an invalid env var name. Consider mapping any non-alphanumeric char to _ for robustness:
| pub fn env_var_prefix(binary_name: &str) -> String { | |
| binary_name.to_uppercase().replace('-', "_") | |
| } | |
| pub fn env_var_prefix(binary_name: &str) -> String { | |
| binary_name | |
| .to_uppercase() | |
| .chars() | |
| .map(|c| if c.is_ascii_alphanumeric() { c } else { '_' }) | |
| .collect() | |
| } |
| .title | ||
| .clone() | ||
| .unwrap_or_else(|| format!("{} CLI", doc.name)); | ||
| let env_prefix = crate::openapi::commands::env_var_prefix(&doc.name); |
There was a problem hiding this comment.
🔵 suggestion
GraphQL command builder reaching into crate::openapi::commands for a generic string helper is odd coupling. Since this is now used from app.rs, openapi, and graphql, consider hoisting env_var_prefix to a shared module (e.g. crate::user_agent or a small env util) and re-exporting.
There was a problem hiding this comment.
Devin Review found 1 potential issue.
2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
…ecific flags Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Description
Stack 4/5 ("Benchling CLI fixes", split out of #17620). Stacked on #17623.
Global flag help leaked literal
<NAME>_OUTPUT/<NAME>_USER_AGENT_SUFFIX, and the generated README documented a global--output <PATH>that doesn't exist and claimed the default format is JSON.Changes Made
openapi/commands.rs:env_var_prefix(binary_name)(benchling-cli→BENCHLING_CLI);app.rs/graphql/commands.rsuse it in--format/--user-agent-suffixhelp andglobal_flags(&self.name)metadata.--formathelp now listsjson, table, yaml, csv, raw, jsonl, httpand states the default (tableon a TTY,jsonwhen piped).emitReadme.ts/emitReference.ts: same format list + default;-o, --output <PATH>documented only for binary-response operations.fix-help-placeholders-docs.yml; regeneratedseed/cli/cli-basic-auth.Testing
cargo buildingenerators/cli/sdk;pnpm turbo run compile --filter @fern-api/cli-generatorpnpm seed test --generator cli --fixture cli-basic-auth --skip-scripts --local2/2 (README/reference diff in seed)benchling --helpshowsBENCHLING_OUTPUT)Link to Devin session: https://app.devin.ai/sessions/d3e6c0a2eab24903ae7765c8a4c54032
Open in Devin Desktop: https://app.devin.ai/desktop/session/d3e6c0a2eab24903ae7765c8a4c54032?variant=devin