Skip to content

Commit 083ccb7

Browse files
authored
doc fixes + propogate errors for baml-cli (#2124)
<!-- ELLIPSIS_HIDDEN --> > [!IMPORTANT] > Enhance CLI error handling and update BAML documentation for Ruby and TypeScript with improved examples and structure. > > - **CLI Error Handling**: > - Propagate errors in `commands.rs` for `Generate`, `Init`, `Serve`, `Dev`, `Auth`, `Login`, `Deploy` commands by printing error messages to stderr. > - **Protobuf Changes**: > - Update `cffi.pb.go` to include `sizeCache` and `unknownFields` in `CFFIValueHolder`, `CFFIFieldTypeChecked`, and `CFFICollector`. > - Conditional `protoimpl.UnsafeEnabled` checks added for message state handling in `CFFIValueChecked` and `CFFICollector`. > - **Documentation Updates**: > - Replace `<CodeBlocks>` with `<Tabs>` in `ruby.mdx` and `typescript.mdx` for better code example organization. > - Add streaming examples for Ruby and TypeScript in `ruby.mdx` and `typescript.mdx`. > - Update `checks-and-asserts.mdx` to include detailed examples of `@assert` and `@check` usage. > - Add examples for async and sync client usage in `client.mdx`. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup> for 77c0ea1. You can [customize](https://app.ellipsis.dev/BoundaryML/settings/summaries) this summary. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN -->
1 parent 6b7c178 commit 083ccb7

11 files changed

Lines changed: 2012 additions & 1020 deletions

File tree

engine/cli/src/commands.rs

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,40 +60,61 @@ impl RuntimeCli {
6060
args.from = BamlRuntime::parse_baml_src_path(&args.from)?;
6161
match args.run(defaults) {
6262
Ok(()) => Ok(crate::ExitCode::Success),
63-
Err(_) => Ok(crate::ExitCode::Other),
63+
Err(e) => {
64+
eprintln!("Error: {e}");
65+
Ok(crate::ExitCode::Other)
66+
}
6467
}
6568
}
6669
Commands::Init(args) => match args.run(defaults) {
6770
Ok(()) => Ok(crate::ExitCode::Success),
68-
Err(_) => Ok(crate::ExitCode::Other),
71+
Err(e) => {
72+
eprintln!("Error: {e}");
73+
Ok(crate::ExitCode::Other)
74+
}
6975
},
7076
Commands::Serve(args) => {
7177
args.from = BamlRuntime::parse_baml_src_path(&args.from)?;
7278
match args.run() {
7379
Ok(()) => Ok(crate::ExitCode::Success),
74-
Err(_) => Ok(crate::ExitCode::Other),
80+
Err(e) => {
81+
eprintln!("Error: {e}");
82+
Ok(crate::ExitCode::Other)
83+
}
7584
}
7685
}
7786
Commands::Dev(args) => {
7887
args.from = BamlRuntime::parse_baml_src_path(&args.from)?;
7988
match args.run(defaults) {
8089
Ok(()) => Ok(crate::ExitCode::Success),
81-
Err(_) => Ok(crate::ExitCode::Other),
90+
Err(e) => {
91+
eprintln!("Error: {e}");
92+
Ok(crate::ExitCode::Other)
93+
}
8294
}
8395
}
8496
Commands::Auth(args) => match t.block_on(async { args.run_async().await }) {
8597
Ok(()) => Ok(crate::ExitCode::Success),
86-
Err(_) => Ok(crate::ExitCode::Other),
98+
Err(e) => {
99+
eprintln!("Error: {e}");
100+
Ok(crate::ExitCode::Other)
101+
}
87102
},
88103
Commands::Login(args) => match t.block_on(async { args.run_async().await }) {
89104
Ok(()) => Ok(crate::ExitCode::Success),
90-
Err(_) => Ok(crate::ExitCode::Other),
105+
Err(e) => {
106+
eprintln!("Error: {e}");
107+
Ok(crate::ExitCode::Other)
108+
}
91109
},
92110
Commands::Deploy(args) => {
93111
args.from = BamlRuntime::parse_baml_src_path(&args.from)?;
94112
match t.block_on(async { args.run_async().await }) {
95113
Ok(()) => Ok(crate::ExitCode::Success),
96-
Err(_) => Ok(crate::ExitCode::Other),
114+
Err(e) => {
115+
eprintln!("Error: {e}");
116+
Ok(crate::ExitCode::Other)
117+
}
97118
}
98119
}
99120
Commands::Format(args) => {

engine/language_client_codegen/src/version_check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ pub fn check_version(
101101
let update_instruction = match generator_language {
102102
GeneratorOutputType::OpenApi => format!("use 'npx @boundaryml/baml@{gen_version}'"),
103103
GeneratorOutputType::PythonPydantic | GeneratorOutputType::PythonPydanticV1 => {
104-
format!("pip install --upgrade baml-py=={gen_version}")
104+
format!("pip install --upgrade baml-py=={gen_version}, or uv add baml-py=={gen_version}")
105105
}
106106
GeneratorOutputType::Typescript => {
107107
format!("npm install --save-dev @boundaryml/baml@{gen_version}")

0 commit comments

Comments
 (0)