Repository navigation
feat(cli): add generator configuration command - #4265
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
⏭️ Performance benchmarks were skippedPerf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to To run them on this PR, do any of the following, then push a commit (or re-run CI):
|
📝 WalkthroughWalkthroughChangesGenerator CLI
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant GenerateArgs
participant AddGeneratorArgs
participant baml.toml
User->>GenerateArgs: generate add OUTPUT_TYPE
GenerateArgs->>AddGeneratorArgs: dispatch add command
AddGeneratorArgs->>baml.toml: insert generator.clientN
baml.toml-->>AddGeneratorArgs: updated manifest
AddGeneratorArgs-->>User: report completion
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Binary size checks passed✅ 7 passed
Generated by |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
baml_language/crates/baml_cli/src/generate.rs (2)
47-59: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider exposing
--output-dironbaml generate add.
Generator.output_dirandadd_generator_to_manifest(Line 169) already support writing anoutput_dirvalue, butAddGeneratorArgshas no corresponding CLI flag, so every generator added via this command always defaults to..+generated_directory()indiscover_generators. Users needing a custom layout must hand-editbaml.tomlafterward.♻️ Suggested addition
pub struct AddGeneratorArgs { #[arg(value_name = "OUTPUT_TYPE", value_parser = add_output_type_parser())] pub output_type: OutputType, /// Project search starting point. Defaults to the current directory. #[arg(long, value_name = "PATH")] pub from: Option<PathBuf>, + /// Output directory override, written to the generator's `output_dir`. + #[arg(long, value_name = "PATH")] + pub output_dir: Option<String>, + /// Go module import path for the generated baml_sdk package. #[arg(long, value_name = "IMPORT_PATH")] pub sdk_import_path: Option<String>, }And in
run():generator.output_dir = self.output_dir.clone();Also applies to: 90-124, 169-171
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@baml_language/crates/baml_cli/src/generate.rs` around lines 47 - 59, Add an optional output_dir PathBuf field with a --output-dir argument to AddGeneratorArgs, then propagate it in run() by assigning the parsed value to generator.output_dir before add_generator_to_manifest. Preserve existing default behavior when the flag is omitted and ensure the value reaches the manifest-writing flow.
855-885: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a Go happy-path test through
AddGeneratorArgs::run().The Go-specific validation branch in
run()(Lines 97-111) is only unit-tested indirectly —add_go_generator_writes_required_import_pathbuilds theGenerator/manifest directly, bypassingrun()'s own match logic. Consider adding a variant ofadd_command_updates_project_manifestwithoutput_type: OutputType::Goand a validsdk_import_pathto cover the actual CLI entry point end-to-end.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@baml_language/crates/baml_cli/src/generate.rs` around lines 855 - 885, The existing add_command_updates_project_manifest test only exercises the TypeScript path; add a parallel happy-path test that invokes AddGeneratorArgs::run() with OutputType::Go and a valid sdk_import_path, then assert success and verify the generated manifest contains the expected Go output type and import path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@baml_language/crates/baml_cli/src/generate.rs`:
- Around line 47-59: Add an optional output_dir PathBuf field with a
--output-dir argument to AddGeneratorArgs, then propagate it in run() by
assigning the parsed value to generator.output_dir before
add_generator_to_manifest. Preserve existing default behavior when the flag is
omitted and ensure the value reaches the manifest-writing flow.
- Around line 855-885: The existing add_command_updates_project_manifest test
only exercises the TypeScript path; add a parallel happy-path test that invokes
AddGeneratorArgs::run() with OutputType::Go and a valid sdk_import_path, then
assert success and verify the generated manifest contains the expected Go output
type and import path.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 8878a961-2466-44d8-a2a0-a37ef561a4f5
⛔ Files ignored due to path filters (1)
baml_language/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (5)
baml_language/crates/baml_cli/Cargo.tomlbaml_language/crates/baml_cli/src/commands.rsbaml_language/crates/baml_cli/src/generate.rsbaml_language/crates/baml_cli/src/init_command.rsbaml_language/crates/baml_codegen_types/src/generator_fields.rs
Changes
baml generate add <output-type>as a real CLI subcommand[generator.clientN]entry while preserving TOML comments and formattingOutputTypeand expose every supported bridge namebaml generate addguidance to newly initializedbaml.tomlfilesTesting
cargo test -p baml_cli --libcargo test -p baml_cli generatecargo clippy -p baml_cli -p baml_codegen_types --tests -- -D warningscargo fmt --all -- --checkbaml initfollowed bybaml generate add python/pydantic2Additional Notes
The Go target requires
--sdk-import-path; target-specific naming defaults are centralized inFrom<OutputType> for Generator.Summary by CodeRabbit
baml generate addto configure a client generator directly inbaml.toml.