Add support for a configuration file
This commit is contained in:
parent
a34dbb7fd3
commit
b9664b43c8
10 changed files with 505 additions and 63 deletions
29
src/args.rs
29
src/args.rs
|
@ -1,51 +1,66 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
use clap::{command, Parser, Subcommand};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Parser)]
|
||||
#[derive(Parser, Serialize)]
|
||||
#[command(version, about, long_about = None)]
|
||||
pub(crate) struct Opts {
|
||||
/// The Immich API URL - it should probably end in "/api"
|
||||
#[arg(short, long)]
|
||||
pub server_url: String,
|
||||
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
|
||||
pub server_url: Option<String>,
|
||||
|
||||
/// The Immich API key
|
||||
#[arg(short, long)]
|
||||
pub api_key: String,
|
||||
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
|
||||
pub api_key: Option<String>,
|
||||
|
||||
/// If enabled, actions that would have been performed are only logged
|
||||
#[arg(short, long)]
|
||||
pub dry_run: bool,
|
||||
|
||||
#[command(subcommand)]
|
||||
#[serde(flatten)]
|
||||
pub command: Commands,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
#[derive(Serialize, Subcommand)]
|
||||
pub(crate) enum Commands {
|
||||
/// People related commands
|
||||
#[serde(rename = "people")]
|
||||
People {
|
||||
#[command(subcommand)]
|
||||
#[serde(flatten)]
|
||||
people_command: PeopleCommands,
|
||||
},
|
||||
/// Server related commands
|
||||
#[serde(rename = "server")]
|
||||
Server {
|
||||
#[command(subcommand)]
|
||||
#[serde(flatten)]
|
||||
server_command: ServerCommands,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
#[derive(Serialize, Subcommand)]
|
||||
pub(crate) enum PeopleCommands {
|
||||
/// Synchronises date of births from a vcard file
|
||||
#[serde(rename = "sync_date_of_births")]
|
||||
SyncDateOfBirths {
|
||||
#[arg(short, long)]
|
||||
vcard_file: PathBuf,
|
||||
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
|
||||
vcard: Option<PathBuf>,
|
||||
},
|
||||
|
||||
/// Lists the people without date of birth
|
||||
#[serde(rename = "missing_date_of_births")]
|
||||
MissingDateOfBirths {},
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
#[derive(Serialize, Subcommand)]
|
||||
pub(crate) enum ServerCommands {
|
||||
/// Fetches the version of the server
|
||||
#[serde(rename = "version")]
|
||||
Version {},
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue