immich-tools/src/args.rs

119 lines
3 KiB
Rust

use std::path::PathBuf;
use clap::{command, Parser, Subcommand};
use clap_verbosity_flag::{InfoLevel, Verbosity};
use serde::Serialize;
#[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)]
#[serde(skip_serializing_if = "::std::option::Option::is_none")]
pub server_url: Option<String>,
/// The Immich API key
#[arg(short, long)]
#[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,
/// If enabled, don't ask for confirmation of destructive actions
#[arg(short, long)]
pub no_confirm: bool,
#[command(subcommand)]
#[serde(flatten)]
pub command: Commands,
#[command(flatten)]
#[serde(skip)]
pub verbose: Verbosity<InfoLevel>,
}
#[derive(Serialize, Subcommand)]
pub(crate) enum Commands {
/// Assets related commands
#[serde(rename = "assets")]
Assets {
#[command(subcommand)]
#[serde(flatten)]
assets_command: AssetsCommands,
},
/// Libraries related commands
#[serde(rename = "libaries")]
Libraries {
#[command(subcommand)]
#[serde(flatten)]
libraries_command: LibrariesCommands,
},
/// 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(Serialize, Subcommand)]
pub(crate) enum AssetsCommands {
/// Delete all assets
#[serde(rename = "delete")]
Delete {
/// Delete only offline assets
#[arg(short, long, action)]
offline: bool,
},
/// List all assets
#[serde(rename = "list")]
List {
/// List only offline assets
#[arg(short, long, action)]
offline: bool,
},
}
#[derive(Serialize, Subcommand)]
pub(crate) enum LibrariesCommands {
/// Scan all libraries
#[serde(rename = "scan")]
Scan {},
}
#[derive(Serialize, Subcommand)]
pub(crate) enum PeopleCommands {
/// Synchronises date of births from a vcard file
#[serde(rename = "sync_date_of_births")]
SyncDateOfBirths {
#[arg(long)]
#[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(Serialize, Subcommand)]
pub(crate) enum ServerCommands {
/// Checks which server features are enabled
#[serde(rename = "features")]
Features {},
/// Fetches the version of the server
#[serde(rename = "version")]
Version {},
}