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
112 changes: 97 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/goose-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ mcp-core = { path = "../mcp-core" }
clap = { version = "4.4", features = ["derive"] }
cliclack = "0.3.5"
console = "0.15.8"
bat = "0.24.0"
bat = "0.25.0"
anyhow = "1.0"
serde_json = "1.0"
tokio = { version = "1.43", features = ["full"] }
Expand Down
11 changes: 11 additions & 0 deletions crates/goose-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,13 @@ enum Command {
)]
quiet: bool,

/// Porcelain mode - redirect all CLI output to stderr and only output final text message to stdout
#[arg(
long = "porcelain",
help = "Porcelain mode. Redirect all CLI output to stderr and only output final text message to stdout"
)]
porcelain: bool,

/// Scheduled job ID (used internally for scheduled executions)
#[arg(
long = "scheduled-job-id",
Expand Down Expand Up @@ -677,6 +684,7 @@ pub async fn cli() -> Result<()> {
scheduled_job_id: None,
interactive: true,
quiet: false,
porcelain: false,
sub_recipes: None,
})
.await;
Expand Down Expand Up @@ -725,6 +733,7 @@ pub async fn cli() -> Result<()> {
render_recipe,
scheduled_job_id,
quiet,
porcelain,
}) => {
let (input_config, session_settings, sub_recipes) = match (
instructions,
Expand Down Expand Up @@ -830,6 +839,7 @@ pub async fn cli() -> Result<()> {
scheduled_job_id,
interactive, // Use the interactive flag from the Run command
quiet,
porcelain,
sub_recipes,
})
.await;
Expand Down Expand Up @@ -949,6 +959,7 @@ pub async fn cli() -> Result<()> {
scheduled_job_id: None,
interactive: true, // Default case is always interactive
quiet: false,
porcelain: false,
sub_recipes: None,
})
.await;
Expand Down
1 change: 1 addition & 0 deletions crates/goose-cli/src/commands/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub async fn agent_generator(
interactive: false, // Benchmarking is non-interactive
scheduled_job_id: None,
quiet: false,
porcelain: false,
sub_recipes: None,
})
.await;
Expand Down
1 change: 1 addition & 0 deletions crates/goose-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use once_cell::sync::Lazy;
pub mod cli;
pub mod commands;
pub mod logging;
pub mod print_macros;
pub mod project_tracker;
pub mod recipes;
pub mod session;
Expand Down
42 changes: 42 additions & 0 deletions crates/goose-cli/src/print_macros.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/// Macro for conditional printing to stderr or stdout based on a boolean flag.
///
/// When `use_stderr` is true, prints to stderr using `eprintln!`.
/// When `use_stderr` is false, prints to stdout using `println!`.
///
/// # Examples
///
/// ```
/// use goose_cli::cli_println;
/// cli_println!(true, "This goes to stderr");
/// cli_println!(false, "This goes to stdout");
/// let some_flag = true;
/// cli_println!(some_flag, "Hello {}", "world");
/// ```
#[macro_export]
macro_rules! cli_println {
($use_stderr:expr, $($arg:tt)*) => {
if $use_stderr {
eprintln!($($arg)*);
} else {
println!($($arg)*);
}
};
}

#[cfg(test)]
mod tests {
#[test]
fn test_cli_println_compiles() {
// Test that the macro compiles with different argument patterns
cli_println!(true, "test");
cli_println!(false, "test {}", "arg");
cli_println!(true, "test {} {}", "arg1", "arg2");

// Test with variables
let use_stderr = true;
cli_println!(use_stderr, "variable test");

let use_stderr = false;
cli_println!(use_stderr, "variable test {}", "with arg");
}
}
Loading
Loading