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
47 changes: 47 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions crates/goose-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ rand = "0.8.5"
rustyline = "15.0.0"
tracing = "0.1"
chrono = "0.4"
colored = "2.2"
comfy-table = "7.1"
humansize = "2.1"
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt", "json", "time"] }
tracing-appender = "0.2"
once_cell = "1.20.2"
Expand Down
88 changes: 88 additions & 0 deletions crates/goose-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,63 @@ enum SchedulerCommand {
CronHelp {},
}

#[derive(Subcommand)]
enum DbCommand {
#[command(about = "Show database status and statistics")]
Status,

#[command(about = "Create a manual database backup")]
Backup {
#[arg(
short,
long,
help = "Custom backup name (saved in default backup directory)"
)]
name: Option<String>,
},

#[command(about = "Restore database from a backup file")]
Restore {
#[arg(help = "Backup filename (e.g., backup_YYYYMMDD_HHMMSS.db) or full path")]
backup_file: PathBuf,

#[arg(short, long, help = "Skip confirmation prompt")]
force: bool,
},

#[command(about = "Show database file path")]
Path,

#[command(about = "List all available database backups")]
ListBackups {
#[arg(
short,
long,
default_value = "table",
help = "Output format (table/json)"
)]
format: String,
},

#[command(about = "Delete database backup files")]
DeleteBackup {
#[arg(
help = "Backup filename(s) (e.g., backup_YYYYMMDD_HHMMSS.db) or full path(s)",
conflicts_with = "all"
)]
backup_files: Vec<PathBuf>,

#[arg(long, help = "Delete all backups", conflicts_with = "backup_files")]
all: bool,

#[arg(long, help = "Also clean up orphaned WAL/SHM files")]
cleanup: bool,

#[arg(short, long, help = "Skip confirmation prompt")]
force: bool,
},
}

#[derive(Subcommand)]
pub enum BenchCommand {
#[command(name = "init-config", about = "Create a new starter-config")]
Expand Down Expand Up @@ -403,6 +460,13 @@ enum Command {
#[command(about = "Configure goose settings")]
Configure {},

/// Database management commands
#[command(about = "Database management commands")]
Db {
#[command(subcommand)]
command: DbCommand,
},

/// Display goose configuration information
#[command(about = "Display goose information")]
Info {
Expand Down Expand Up @@ -848,6 +912,7 @@ pub async fn cli() -> anyhow::Result<()> {

let command_name = match &cli.command {
Some(Command::Configure {}) => "configure",
Some(Command::Db { .. }) => "db",
Some(Command::Info { .. }) => "info",
Some(Command::Mcp { .. }) => "mcp",
Some(Command::Acp {}) => "acp",
Expand All @@ -873,6 +938,29 @@ pub async fn cli() -> anyhow::Result<()> {
Some(Command::Configure {}) => {
handle_configure().await?;
}
Some(Command::Db { command }) => {
match command {
DbCommand::Status => crate::commands::db::handle_db_status().await?,
DbCommand::Backup { name } => crate::commands::db::handle_db_backup(name).await?,
DbCommand::Restore { backup_file, force } => {
crate::commands::db::handle_db_restore(backup_file, force).await?
}
DbCommand::Path => crate::commands::db::handle_db_path().await?,
DbCommand::ListBackups { format } => {
crate::commands::db::handle_db_list_backups(format).await?
}
DbCommand::DeleteBackup {
backup_files,
all,
cleanup,
force,
} => {
crate::commands::db::handle_db_delete_backup(backup_files, all, cleanup, force)
.await?
}
}
return Ok(());
}
Some(Command::Info { verbose }) => {
handle_info(verbose)?;
}
Expand Down
Loading