Skip to content

Commit f73c76f

Browse files
committed
ix: add no_input to BaseArgs test fixtures and simplify eval SSE parsing
1 parent 3d60e8a commit f73c76f

7 files changed

Lines changed: 17 additions & 8 deletions

File tree

src/args.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ pub struct BaseArgs {
2828
#[arg(long, env = "BRAINTRUST_NO_COLOR", global = true, value_parser = clap::builder::BoolishValueParser::new(), default_value_t = false)]
2929
pub no_color: bool,
3030

31+
/// Disable all interactive prompts
32+
#[arg(long, env = "BRAINTRUST_NO_INPUT", global = true, value_parser = clap::builder::BoolishValueParser::new(), default_value_t = false)]
33+
pub no_input: bool,
34+
3135
/// Use a saved login profile (or via BRAINTRUST_PROFILE)
3236
#[arg(long, env = "BRAINTRUST_PROFILE", global = true)]
3337
pub profile: Option<String>,

src/auth.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2708,6 +2708,7 @@ mod tests {
27082708
verbose: false,
27092709
quiet: false,
27102710
no_color: false,
2711+
no_input: false,
27112712
profile: None,
27122713
project: None,
27132714
org_name: None,

src/functions/push.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3436,6 +3436,7 @@ mod tests {
34363436
verbose: false,
34373437
quiet: false,
34383438
no_color: false,
3439+
no_input: false,
34393440
profile: None,
34403441
org_name: None,
34413442
project: None,

src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ mod tests {
404404
verbose: false,
405405
quiet: false,
406406
no_color: false,
407+
no_input: false,
407408
profile: None,
408409
org_name: None,
409410
project: None,

src/switch.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ mod tests {
256256
verbose: false,
257257
quiet: false,
258258
no_color: false,
259+
no_input: false,
259260
profile: None,
260261
org_name: org.map(String::from),
261262
project: project.map(String::from),

src/traces.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6061,6 +6061,7 @@ mod tests {
60616061
verbose: false,
60626062
quiet: false,
60636063
no_color: false,
6064+
no_input: false,
60646065
profile: None,
60656066
org_name: None,
60666067
project: None,

tests/eval_dev_server.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ fn parse_sse_events(body: &str) -> Vec<SseEvent> {
167167
let mut current_data = Vec::<String>::new();
168168

169169
for line in body.lines() {
170-
if line.starts_with("event: ") {
171-
current_event = line["event: ".len()..].to_string();
172-
} else if line.starts_with("data: ") {
173-
current_data.push(line["data: ".len()..].to_string());
170+
if let Some(stripped) = line.strip_prefix("event: ") {
171+
current_event = stripped.to_string();
172+
} else if let Some(stripped) = line.strip_prefix("data: ") {
173+
current_data.push(stripped.to_string());
174174
} else if line.is_empty() && !current_event.is_empty() {
175175
events.push(SseEvent {
176176
event: std::mem::take(&mut current_event),
@@ -562,10 +562,10 @@ fn streaming_eval_post(
562562
Ok(l) => l,
563563
Err(_) => break,
564564
};
565-
if line.starts_with("event: ") {
566-
current_event = line["event: ".len()..].to_string();
567-
} else if line.starts_with("data: ") {
568-
current_data.push(line["data: ".len()..].to_string());
565+
if let Some(stripped) = line.strip_prefix("event: ") {
566+
current_event = stripped.to_string();
567+
} else if let Some(stripped) = line.strip_prefix("data: ") {
568+
current_data.push(stripped.to_string());
569569
} else if line.is_empty() && !current_event.is_empty() {
570570
let event = SseEvent {
571571
event: std::mem::take(&mut current_event),

0 commit comments

Comments
 (0)