mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-11-28 13:09:10 -05:00
bpaf improvements
* use latest published crate. This is a build fix: it was broken when the `exit_code` branch was deleted from the `bpaf` repo, even though the commit still exists! https://github.com/scottlamb/moonfire-nvr/pull/259 * clean up `db-dir` parsing redundancy, as suggested here: https://github.com/pacak/bpaf/discussions/165#discussioncomment-4983158
This commit is contained in:
@@ -13,10 +13,7 @@ use std::path::PathBuf;
|
||||
#[derive(Bpaf, Debug)]
|
||||
#[bpaf(options)]
|
||||
pub struct Args {
|
||||
/// Directory holding the SQLite3 index database.
|
||||
///
|
||||
/// default: `/var/lib/moonfire-nvr/db`.
|
||||
#[bpaf(argument("PATH"), fallback_with(crate::default_db_dir))]
|
||||
#[bpaf(external(crate::parse_db_dir))]
|
||||
db_dir: PathBuf,
|
||||
|
||||
/// Compares sample file lengths on disk to the database.
|
||||
|
||||
@@ -23,10 +23,7 @@ mod users;
|
||||
#[derive(Bpaf, Debug)]
|
||||
#[bpaf(options)]
|
||||
pub struct Args {
|
||||
/// Directory holding the SQLite3 index database.
|
||||
///
|
||||
/// default: `/var/lib/moonfire-nvr/db`.
|
||||
#[bpaf(argument("PATH"), fallback_with(crate::default_db_dir))]
|
||||
#[bpaf(external(crate::parse_db_dir))]
|
||||
db_dir: PathBuf,
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,7 @@ use std::path::PathBuf;
|
||||
#[derive(Bpaf, Debug)]
|
||||
#[bpaf(options)]
|
||||
pub struct Args {
|
||||
/// Directory holding the SQLite3 index database.
|
||||
///
|
||||
/// default: `/var/lib/moonfire-nvr/db`.
|
||||
#[bpaf(argument("PATH"), fallback_with(crate::default_db_dir))]
|
||||
#[bpaf(external(crate::parse_db_dir))]
|
||||
db_dir: PathBuf,
|
||||
}
|
||||
|
||||
|
||||
@@ -33,10 +33,7 @@ fn parse_flags(flags: String) -> Result<Vec<SessionFlag>, Error> {
|
||||
#[derive(Bpaf, Debug, PartialEq, Eq)]
|
||||
#[bpaf(options)]
|
||||
pub struct Args {
|
||||
/// Directory holding the SQLite3 index database.
|
||||
///
|
||||
/// default: `/var/lib/moonfire-nvr/db`.
|
||||
#[bpaf(argument("PATH"), fallback_with(crate::default_db_dir))]
|
||||
#[bpaf(external(crate::parse_db_dir))]
|
||||
db_dir: PathBuf,
|
||||
|
||||
/// Creates a session with the given permissions, as a JSON object.
|
||||
@@ -173,7 +170,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
args,
|
||||
Args {
|
||||
db_dir: crate::default_db_dir().unwrap(),
|
||||
db_dir: crate::DEFAULT_DB_DIR.into(),
|
||||
domain: None,
|
||||
curl_cookie_jar: None,
|
||||
permissions: Some(crate::json::Permissions {
|
||||
|
||||
@@ -12,7 +12,7 @@ use serde::Deserialize;
|
||||
use crate::json::Permissions;
|
||||
|
||||
fn default_db_dir() -> PathBuf {
|
||||
"/var/lib/moonfire-nvr/db".into()
|
||||
crate::DEFAULT_DB_DIR.into()
|
||||
}
|
||||
|
||||
fn default_ui_dir() -> PathBuf {
|
||||
|
||||
@@ -20,10 +20,7 @@ use std::process::Command;
|
||||
#[derive(Bpaf, Debug, PartialEq, Eq)]
|
||||
#[bpaf(options)]
|
||||
pub struct Args {
|
||||
/// Directory holding the SQLite3 index database.
|
||||
///
|
||||
/// default: `/var/lib/moonfire-nvr/db`.
|
||||
#[bpaf(fallback_with(crate::default_db_dir))]
|
||||
#[bpaf(external(crate::parse_db_dir))]
|
||||
db_dir: PathBuf,
|
||||
|
||||
/// Opens the database in read-only mode and locks it only for shared access.
|
||||
|
||||
@@ -12,11 +12,7 @@ use failure::Error;
|
||||
#[derive(Bpaf, Debug)]
|
||||
#[bpaf(options)]
|
||||
pub struct Args {
|
||||
/// Directory holding the SQLite3 index database.
|
||||
///
|
||||
///
|
||||
/// default: `/var/lib/moonfire-nvr/db`.
|
||||
#[bpaf(argument("PATH"), fallback_with(crate::default_db_dir))]
|
||||
#[bpaf(external(crate::parse_db_dir))]
|
||||
db_dir: std::path::PathBuf,
|
||||
|
||||
/// When upgrading from schema version 1 to 2, the sample file directory.
|
||||
|
||||
Reference in New Issue
Block a user