extend "moonfire-nvr sql" to pass args to sqlite3

This commit is contained in:
Scott Lamb 2019-06-19 20:15:12 -07:00
parent a6ebf2d10d
commit 004aa5d6ce

View File

@ -40,9 +40,12 @@ Runs a SQLite shell on the Moonfire NVR database with locking.
Usage:
moonfire-nvr sql [options]
moonfire-nvr sql [options] [--] [<arg>...]
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<String>,
}
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(())
}