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, /// The Immich API key #[arg(short, long)] #[serde(skip_serializing_if = "::std::option::Option::is_none")] pub api_key: Option, /// 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, } #[derive(Serialize, Subcommand)] pub(crate) enum Commands { /// Albums related commands #[serde(rename = "albums")] Albums { #[command(subcommand)] #[serde(flatten)] albums_command: AlbumsCommands, }, /// 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 AlbumsCommands { /// Create albums automatically from external libaries folder structure #[serde(rename = "auto-create")] AutoCreate { /// String to use when composing album names from nested folder structures #[arg(long, default_value = " / ")] album_name_separator: String, }, /// Delete all albums #[serde(rename = "delete")] Delete { /// Delete only empty albums #[arg(short, long, action)] empty: bool, }, /// List all albums #[serde(rename = "list")] List {}, } #[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 { /// List all libraries #[serde(rename = "list")] List {}, /// 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, }, /// 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 {}, }