Skip to content
Open
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
10 changes: 3 additions & 7 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ pub struct BaseArgs {
#[arg(long, global = true)]
pub json: bool,

/// Suppress non-essential output
#[arg(long, short = 'q', env = "BRAINTRUST_QUIET", global = true, value_parser = clap::builder::BoolishValueParser::new(), default_value_t = false)]
pub quiet: bool,
/// Verbose mode — set at runtime by subcommands that support it
#[arg(skip)]
pub verbose: bool,

/// Disable ANSI color output
#[arg(long, env = "BRAINTRUST_NO_COLOR", global = true, value_parser = clap::builder::BoolishValueParser::new(), default_value_t = false)]
Expand Down Expand Up @@ -44,10 +44,6 @@ pub struct BaseArgs {
#[arg(long, global = true)]
pub prefer_profile: bool,

/// Disable all interactive prompts
#[arg(long, global = true)]
pub no_input: bool,

/// Override API URL (or via BRAINTRUST_API_URL)
#[arg(
long,
Expand Down
20 changes: 6 additions & 14 deletions src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -779,17 +779,7 @@ async fn run_login_oauth(base: &BaseArgs, args: AuthLoginArgs) -> Result<()> {
Ok(())
}

pub async fn login_interactive(base: &mut BaseArgs) -> Result<String> {
let methods = ["OAuth (browser)", "API key"];
let selected = ui::fuzzy_select("Select login method", &methods, 0)?;

if selected == 0 {
login_interactive_oauth(base).await
} else {
login_interactive_api_key(base).await
}
}

#[allow(dead_code)]
async fn login_interactive_api_key(base: &mut BaseArgs) -> Result<String> {
let api_key = prompt_api_key()?;

Expand Down Expand Up @@ -825,7 +815,7 @@ async fn login_interactive_api_key(base: &mut BaseArgs) -> Result<String> {
Ok(profile_name)
}

async fn login_interactive_oauth(base: &mut BaseArgs) -> Result<String> {
pub(crate) async fn login_interactive_oauth(base: &mut BaseArgs) -> Result<String> {
let api_url = base
.api_url
.clone()
Expand Down Expand Up @@ -863,7 +853,9 @@ async fn login_interactive_oauth(base: &mut BaseArgs) -> Result<String> {

let _ = open::that(&authorize_url);
eprintln!("Complete authorization in your browser.");
eprintln!();
eprintln!("{}", dialoguer::console::style(&authorize_url).dim());
eprintln!();

let callback = collect_oauth_callback(listener, is_ssh_session()).await?;
if let Some(error) = callback.error {
Expand Down Expand Up @@ -1717,6 +1709,7 @@ async fn collect_oauth_callback(
let pasted = Input::<String>::new()
.with_prompt("Callback URL/query/JSON (press Enter to wait for automatic callback)")
.allow_empty(true)
.report(false)
.interact_text()
.context("failed to read callback URL")?;
if pasted.trim().is_empty() {
Expand Down Expand Up @@ -2580,14 +2573,13 @@ mod tests {
fn make_base() -> BaseArgs {
BaseArgs {
json: false,
quiet: false,
verbose: false,
no_color: false,
profile: None,
project: None,
org_name: None,
api_key: None,
prefer_profile: false,
no_input: false,
api_url: None,
app_url: None,
env_file: None,
Expand Down
3 changes: 1 addition & 2 deletions src/functions/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3359,14 +3359,13 @@ mod tests {
fn test_base_args() -> BaseArgs {
BaseArgs {
json: false,
quiet: false,
verbose: false,
no_color: false,
profile: None,
org_name: None,
project: None,
api_key: None,
prefer_profile: false,
no_input: false,
api_url: None,
app_url: None,
env_file: None,
Expand Down
11 changes: 2 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ Flags
--profile <PROFILE> Use a saved login profile [env: BRAINTRUST_PROFILE]
-o, --org <ORG> Override active org [env: BRAINTRUST_ORG_NAME]
-p, --project <PROJECT> Override active project [env: BRAINTRUST_DEFAULT_PROJECT]
-q, --quiet Suppress non-essential output
--json Output as JSON
--no-color Disable ANSI color output
--no-input Disable all interactive prompts
Expand Down Expand Up @@ -249,14 +248,8 @@ fn configure_output(base: &BaseArgs) {
ui::set_animations_enabled(false);
}

if base.quiet {
ui::set_quiet(true);
ui::set_animations_enabled(false);
}

if base.no_input {
ui::set_no_input(true);
}
ui::set_quiet(true);
ui::set_animations_enabled(false);

if disable_color {
dialoguer::console::set_colors_enabled(false);
Expand Down
Loading
Loading