From 004aa5d6ceb43835c9c2b43a208ea51199a5589a Mon Sep 17 00:00:00 2001 From: Scott Lamb Date: Wed, 19 Jun 2019 20:15:12 -0700 Subject: [PATCH] extend "moonfire-nvr sql" to pass args to sqlite3 --- src/cmds/sql.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cmds/sql.rs b/src/cmds/sql.rs index e08f031..f98f5fd 100644 --- a/src/cmds/sql.rs +++ b/src/cmds/sql.rs @@ -40,9 +40,12 @@ Runs a SQLite shell on the Moonfire NVR database with locking. Usage: - moonfire-nvr sql [options] + moonfire-nvr sql [options] [--] [...] moonfire-nvr sql --help +Positional arguments will be passed to sqlite3. Use the -- separator to pass +sqlite3 options, as in "moonfire-nvr sql -- -line 'select username from user'". + Options: --db-dir=DIR Set the directory holding the SQLite3 index database. @@ -55,6 +58,7 @@ Options: struct Args { flag_db_dir: String, flag_read_only: bool, + arg_arg: Vec, } pub fn run() -> Result<(), Error> { @@ -66,6 +70,6 @@ pub fn run() -> Result<(), Error> { if args.flag_read_only { db.push_str("?mode=ro"); } - Command::new("sqlite3").arg(&db).status()?; + Command::new("sqlite3").arg(&db).args(&args.arg_arg).status()?; Ok(()) }