Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Braintrust CLI (`bt`)

test

## Current Limitations

- `bt eval` is currently Unix-only (Linux/macOS). Windows support is planned.
Expand Down
16 changes: 0 additions & 16 deletions src/auth.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
use std::collections::{BTreeMap, BTreeSet};
use std::error::Error as StdError;
use std::fs;
use std::io::{IsTerminal, Write};
use std::net::TcpListener;
use std::path::{Path, PathBuf};
use std::process::Command;
use std::sync::{
atomic::{AtomicBool, Ordering},
Mutex,
};
use std::time::Duration;

use actix_web::{dev::ServerHandle, web, App, HttpResponse, HttpServer};
use anyhow::{bail, Context, Result};
use base64::Engine as _;
use braintrust_sdk_rust::{BraintrustClient, LoginState};
use chrono::{DateTime, Months, Utc};
use clap::{Args, Subcommand};
use crossterm::event::{self, Event, KeyCode, KeyEventKind};
Expand Down Expand Up @@ -1205,7 +1189,7 @@

let api_key = match base.api_key.clone() {
Some(value) if !value.trim().is_empty() => value,
Some(_) => bail!("api key cannot be empty"),

Check failure on line 1192 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

cannot find macro `bail` in this scope

Check failure on line 1192 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

cannot find macro `bail` in this scope

Check failure on line 1192 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

cannot find macro `bail` in this scope

Check failure on line 1192 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

cannot find macro `bail` in this scope
None => prompt_api_key()?,
};

Expand Down Expand Up @@ -1554,7 +1538,7 @@
}
}

bail!("no profile selected; pass --profile <NAME>, set BRAINTRUST_PROFILE, or configure an org")

Check failure on line 1541 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

cannot find macro `bail` in this scope

Check failure on line 1541 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

cannot find macro `bail` in this scope

Check failure on line 1541 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

cannot find macro `bail` in this scope

Check failure on line 1541 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

cannot find macro `bail` in this scope
}

fn resolve_profile_name(
Expand Down Expand Up @@ -2302,7 +2286,7 @@
.unwrap_or_else(|| DEFAULT_API_URL.to_string()));
}

bail!(

Check failure on line 2289 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

cannot find macro `bail` in this scope

Check failure on line 2289 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

cannot find macro `bail` in this scope

Check failure on line 2289 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

cannot find macro `bail` in this scope

Check failure on line 2289 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

cannot find macro `bail` in this scope
"multiple organizations expose different API URLs; choose an organization or pass --api-url explicitly"
)
}
Expand Down Expand Up @@ -2668,10 +2652,10 @@
bail!("callback JSON contains an empty code");
}
if params.error.as_deref().is_some_and(str::is_empty) {
bail!("callback JSON contains an empty error");

Check failure on line 2655 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

cannot find macro `bail` in this scope

Check failure on line 2655 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

cannot find macro `bail` in this scope

Check failure on line 2655 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

cannot find macro `bail` in this scope

Check failure on line 2655 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

cannot find macro `bail` in this scope
}
if params.code.is_none() && params.error.is_none() {
bail!("callback JSON must include code or error");

Check failure on line 2658 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

cannot find macro `bail` in this scope

Check failure on line 2658 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

cannot find macro `bail` in this scope

Check failure on line 2658 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

cannot find macro `bail` in this scope

Check failure on line 2658 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

cannot find macro `bail` in this scope
}
Ok(params)
}
Expand Down Expand Up @@ -2788,7 +2772,7 @@
if !response.status().is_success() {
let status = response.status();
let body = response.text().await.unwrap_or_default();
bail!("oauth token request failed ({status}): {body}");

Check failure on line 2775 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

cannot find macro `bail` in this scope

Check failure on line 2775 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

cannot find macro `bail` in this scope

Check failure on line 2775 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

cannot find macro `bail` in this scope

Check failure on line 2775 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

cannot find macro `bail` in this scope
}

response
Expand Down Expand Up @@ -2832,7 +2816,7 @@
.context("failed to read API key")?;

if api_key.trim().is_empty() {
bail!("api key cannot be empty");

Check failure on line 2819 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

cannot find macro `bail` in this scope

Check failure on line 2819 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

cannot find macro `bail` in this scope

Check failure on line 2819 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

cannot find macro `bail` in this scope

Check failure on line 2819 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

cannot find macro `bail` in this scope
}

Ok(api_key)
Expand Down Expand Up @@ -2966,7 +2950,7 @@

#[cfg(unix)]
{
use std::os::unix::fs::PermissionsExt;

Check warning on line 2953 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

unused import: `std::os::unix::fs::PermissionsExt`

Check warning on line 2953 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

unused import: `std::os::unix::fs::PermissionsExt`

Check warning on line 2953 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

unused import: `std::os::unix::fs::PermissionsExt`

Check warning on line 2953 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

unused import: `std::os::unix::fs::PermissionsExt`
fs::set_permissions(&temp_path, fs::Permissions::from_mode(0o600)).with_context(|| {
format!(
"failed to set permissions on temp secret store {}",
Expand All @@ -2985,7 +2969,7 @@

#[cfg(unix)]
{
use std::os::unix::fs::PermissionsExt;

Check warning on line 2972 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

unused import: `std::os::unix::fs::PermissionsExt`

Check warning on line 2972 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

unused import: `std::os::unix::fs::PermissionsExt`

Check warning on line 2972 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

unused import: `std::os::unix::fs::PermissionsExt`

Check warning on line 2972 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

unused import: `std::os::unix::fs::PermissionsExt`
fs::set_permissions(&path, fs::Permissions::from_mode(0o600)).with_context(|| {
format!(
"failed to set permissions on secret store {}",
Expand Down Expand Up @@ -3067,7 +3051,7 @@
return Err(linux_secret_service_error());
}

bail!(

Check failure on line 3054 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

cannot find macro `bail` in this scope

Check failure on line 3054 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

cannot find macro `bail` in this scope

Check failure on line 3054 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

cannot find macro `bail` in this scope

Check failure on line 3054 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

cannot find macro `bail` in this scope
"failed to store credential in Linux keychain: {}",
stderr.trim()
);
Expand Down Expand Up @@ -3146,7 +3130,7 @@
return Ok(None);
}

bail!(

Check failure on line 3133 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

cannot find macro `bail` in this scope

Check failure on line 3133 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

cannot find macro `bail` in this scope

Check failure on line 3133 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

cannot find macro `bail` in this scope

Check failure on line 3133 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

cannot find macro `bail` in this scope
"failed to load credential from Linux keychain: {}",
stderr.trim()
);
Expand Down Expand Up @@ -3211,7 +3195,7 @@
return Ok(());
}

bail!(

Check failure on line 3198 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

cannot find macro `bail` in this scope

Check failure on line 3198 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

cannot find macro `bail` in this scope

Check failure on line 3198 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

cannot find macro `bail` in this scope

Check failure on line 3198 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

cannot find macro `bail` in this scope
"failed to delete credential from Linux keychain: {}",
stderr.trim()
);
Expand Down Expand Up @@ -3382,7 +3366,7 @@

#[cfg(unix)]
{
use std::os::unix::fs::PermissionsExt;

Check warning on line 3369 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

unused import: `std::os::unix::fs::PermissionsExt`

Check warning on line 3369 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

unused import: `std::os::unix::fs::PermissionsExt`

Check warning on line 3369 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

unused import: `std::os::unix::fs::PermissionsExt`

Check warning on line 3369 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

unused import: `std::os::unix::fs::PermissionsExt`
fs::set_permissions(&temp_path, fs::Permissions::from_mode(0o600)).with_context(|| {
format!(
"failed to set permissions on temp auth config {}",
Expand All @@ -3401,7 +3385,7 @@

#[cfg(unix)]
{
use std::os::unix::fs::PermissionsExt;

Check warning on line 3388 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

unused import: `std::os::unix::fs::PermissionsExt`

Check warning on line 3388 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

unused import: `std::os::unix::fs::PermissionsExt`

Check warning on line 3388 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 22)

unused import: `std::os::unix::fs::PermissionsExt`

Check warning on line 3388 in src/auth.rs

View workflow job for this annotation

GitHub Actions / eval-tests-node (node 20)

unused import: `std::os::unix::fs::PermissionsExt`
fs::set_permissions(path, fs::Permissions::from_mode(0o600)).with_context(|| {
format!(
"failed to set permissions on auth config {}",
Expand Down
Loading