Add .copy CLI command

This commit is contained in:
PThorpe92
2025-08-04 18:58:28 -04:00
parent 039fe22405
commit 736f78de64
3 changed files with 16 additions and 1 deletions

View File

@@ -713,6 +713,11 @@ impl Limbo {
HeadersMode::Off => false, HeadersMode::Off => false,
}; };
} }
Command::Copy(args) => {
if let Err(e) = self.conn.copy_db(&args.output_file) {
let _ = self.writeln(e.to_string());
}
}
}, },
} }
} }

View File

@@ -143,6 +143,11 @@ pub struct HeadersArgs {
pub mode: HeadersMode, pub mode: HeadersMode,
} }
#[derive(Debug, Clone, Args)]
pub struct CopyArgs {
pub output_file: String,
}
#[derive(ValueEnum, Copy, Clone, Debug, PartialEq, Eq)] #[derive(ValueEnum, Copy, Clone, Debug, PartialEq, Eq)]
pub enum HeadersMode { pub enum HeadersMode {
On, On,

View File

@@ -9,7 +9,10 @@ use args::{
use clap::Parser; use clap::Parser;
use import::ImportArgs; use import::ImportArgs;
use crate::input::{AFTER_HELP_MSG, BEFORE_HELP_MSG}; use crate::{
commands::args::CopyArgs,
input::{AFTER_HELP_MSG, BEFORE_HELP_MSG},
};
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
#[command( #[command(
@@ -86,6 +89,8 @@ pub enum Command {
/// Toggle column headers on/off in list mode /// Toggle column headers on/off in list mode
#[command(name = "headers", display_name = ".headers")] #[command(name = "headers", display_name = ".headers")]
Headers(HeadersArgs), Headers(HeadersArgs),
#[command(name = "copy", display_name = ".copy")]
Copy(CopyArgs),
} }
const _HELP_TEMPLATE: &str = "{before-help}{name} const _HELP_TEMPLATE: &str = "{before-help}{name}