Update clap

This commit is contained in:
asonix 2022-09-28 18:23:41 -05:00
parent 656b0225af
commit 3ceaaa391c
5 changed files with 148 additions and 179 deletions

34
Cargo.lock generated
View File

@ -474,26 +474,24 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "clap" name = "clap"
version = "3.2.22" version = "4.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750" checksum = "31c9484ccdc4cb8e7b117cbd0eb150c7c0f04464854e4679aeb50ef03b32d003"
dependencies = [ dependencies = [
"atty", "atty",
"bitflags", "bitflags",
"clap_derive", "clap_derive",
"clap_lex", "clap_lex",
"indexmap",
"once_cell", "once_cell",
"strsim", "strsim",
"termcolor", "termcolor",
"textwrap",
] ]
[[package]] [[package]]
name = "clap_derive" name = "clap_derive"
version = "3.2.18" version = "4.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" checksum = "ca689d7434ce44517a12a89456b2be4d1ea1cafcd8f581978c03d45f5a5c12a7"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro-error", "proc-macro-error",
@ -504,9 +502,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_lex" name = "clap_lex"
version = "0.2.4" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8"
dependencies = [ dependencies = [
"os_str_bytes", "os_str_bytes",
] ]
@ -1558,7 +1556,7 @@ dependencies = [
[[package]] [[package]]
name = "pict-rs" name = "pict-rs"
version = "0.4.0-beta.1" version = "0.4.0-beta.2"
dependencies = [ dependencies = [
"actix-form-data", "actix-form-data",
"actix-rt", "actix-rt",
@ -1683,9 +1681,9 @@ dependencies = [
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.44" version = "1.0.45"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7bd7356a8122b6c4a24a82b278680c73357984ca2fc79a0f9fa6dea7dced7c58" checksum = "3edcd08cf4fea98d1ae6c9ddd3b8ccb1acac7c3693d62625969a7daa04a2ae36"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
@ -2170,12 +2168,6 @@ dependencies = [
"winapi-util", "winapi-util",
] ]
[[package]]
name = "textwrap"
version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16"
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.37" version = "1.0.37"
@ -2343,9 +2335,9 @@ dependencies = [
[[package]] [[package]]
name = "tonic" name = "tonic"
version = "0.8.1" version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11cd56bdb54ef93935a6a79dbd1d91f1ebd4c64150fd61654031fd6b8b775c91" checksum = "55b9af819e54b8f33d453655bef9b9acc171568fb49523078d0cc4e7484200ec"
dependencies = [ dependencies = [
"async-stream", "async-stream",
"async-trait", "async-trait",
@ -2375,9 +2367,9 @@ dependencies = [
[[package]] [[package]]
name = "tonic-build" name = "tonic-build"
version = "0.8.0" version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fbcd2800e34e743b9ae795867d5f77b535d3a3be69fd731e39145719752df8c" checksum = "48c6fd7c2581e36d63388a9e04c350c21beb7a8b059580b2e93993c526899ddc"
dependencies = [ dependencies = [
"prettyplease", "prettyplease",
"proc-macro2", "proc-macro2",

View File

@ -1,7 +1,7 @@
[package] [package]
name = "pict-rs" name = "pict-rs"
description = "A simple image hosting service" description = "A simple image hosting service"
version = "0.4.0-beta.1" version = "0.4.0-beta.2"
authors = ["asonix <asonix@asonix.dog>"] authors = ["asonix <asonix@asonix.dog>"]
license = "AGPL-3.0" license = "AGPL-3.0"
readme = "README.md" readme = "README.md"
@ -27,7 +27,7 @@ anyhow = "1.0"
async-trait = "0.1.51" async-trait = "0.1.51"
awc = { version = "3.0.0", default-features = false, features = ["rustls"] } awc = { version = "3.0.0", default-features = false, features = ["rustls"] }
base64 = "0.13.0" base64 = "0.13.0"
clap = { version = "3.1.6", features = ["derive"] } clap = { version = "4.0.2", features = ["derive"] }
color-eyre = "0.6" color-eyre = "0.6"
config = "0.13.0" config = "0.13.0"
console-subscriber = "0.1" console-subscriber = "0.1"

165
README.md
View File

@ -9,111 +9,88 @@ _a simple image hosting service_
## Usage ## Usage
### Running ### Running
``` ```
pict-rs 0.4.0-beta.1 $ pict-rs -h
asonix <asonix@asonix.dog>
A simple image hosting service A simple image hosting service
USAGE: Usage: pict-rs [OPTIONS] <COMMAND>
pict-rs [OPTIONS] <SUBCOMMAND>
OPTIONS: Commands:
-c, --config-file <CONFIG_FILE> run Runs the pict-rs web server
Path to the pict-rs configuration file filesystem Migrate from the provided filesystem storage
object-storage Migrate from the provided object storage
help Print this message or the help of the given subcommand(s)
--console-address <CONSOLE_ADDRESS> Options:
Address and port to expose tokio-console metrics -c, --config-file <CONFIG_FILE>
Path to the pict-rs configuration file
--console-buffer-capacity <CONSOLE_BUFFER_CAPACITY> --old-db-path <OLD_DB_PATH>
Capacity of the console-subscriber Event Buffer Path to the old pict-rs sled database
--log-format <LOG_FORMAT>
-h, --help Format of logs printed to stdout [possible values: compact, json, normal, pretty]
Print help information --log-targets <LOG_TARGETS>
Log levels to print to stdout, respects RUST_LOG formatting
--log-format <LOG_FORMAT> --console-address <CONSOLE_ADDRESS>
Format of logs printed to stdout Address and port to expose tokio-console metrics
--console-buffer-capacity <CONSOLE_BUFFER_CAPACITY>
--log-targets <LOG_TARGETS> Capacity of the console-subscriber Event Buffer
Log levels to print to stdout, respects RUST_LOG formatting --opentelemetry-url <OPENTELEMETRY_URL>
URL to send OpenTelemetry metrics
--old-db-path <OLD_DB_PATH> --opentelemetry-service-name <OPENTELEMETRY_SERVICE_NAME>
Path to the old pict-rs sled database Service Name to use for OpenTelemetry
--opentelemetry-targets <OPENTELEMETRY_TARGETS>
--opentelemetry-service-name <OPENTELEMETRY_SERVICE_NAME> Log levels to use for OpenTelemetry, respects RUST_LOG formatting
Service Name to use for OpenTelemetry --save-to <SAVE_TO>
File to save the current configuration for reproducible runs
--opentelemetry-targets <OPENTELEMETRY_TARGETS> -h, --help
Log levels to use for OpenTelemetry, respects RUST_LOG formatting Print help information
-V, --version
--opentelemetry-url <OPENTELEMETRY_URL> Print version information
URL to send OpenTelemetry metrics
--save-to <SAVE_TO>
File to save the current configuration for reproducible runs
-V, --version
Print version information
SUBCOMMANDS:
filesystem Migrate from the provided filesystem storage
help Print this message or the help of the given subcommand(s)
object-storage Migrate from the provided object storage
run Runs the pict-rs web server
``` ```
``` ```
pict-rs-run $ pict-rs run -h
Runs the pict-rs web server Runs the pict-rs web server
USAGE: Usage: pict-rs run [OPTIONS] [COMMAND]
pict-rs run [OPTIONS] [SUBCOMMAND]
OPTIONS: Commands:
-a, --address <ADDRESS> filesystem Run pict-rs with filesystem storage
The address and port to bind the pict-rs web server object-storage Run pict-rs with object storage
help Print this message or the help of the given subcommand(s)
--api-key <API_KEY> Options:
The API KEY required to access restricted routes -a, --address <ADDRESS>
The address and port to bind the pict-rs web server
-h, --help --api-key <API_KEY>
Print help information The API KEY required to access restricted routes
--worker-id <WORKER_ID>
--media-cache-duration <MEDIA_CACHE_DURATION> ID of this pict-rs node. Doesn't do much yet
How long, in hours, to keep media ingested through the "cached" endpoint --media-preprocess-steps <MEDIA_PREPROCESS_STEPS>
Optional pre-processing steps for uploaded media
--media-enable-silent-video <MEDIA_ENABLE_SILENT_VIDEO> --media-skip-validate-imports <MEDIA_SKIP_VALIDATE_IMPORTS>
Whether to enable GIF and silent MP4 uploads. Full videos are unsupported Whether to validate media on the "import" endpoint [possible values: true, false]
--media-max-width <MEDIA_MAX_WIDTH>
--media-filters <MEDIA_FILTERS> The maximum width, in pixels, for uploaded media
Which media filters should be enabled on the `process` endpoint --media-max-height <MEDIA_MAX_HEIGHT>
The maximum height, in pixels, for uploaded media
--media-format <MEDIA_FORMAT> --media-max-area <MEDIA_MAX_AREA>
Enforce uploaded media is transcoded to the provided format The maximum area, in pixels, for uploaded media
--media-max-file-size <MEDIA_MAX_FILE_SIZE>
--media-max-area <MEDIA_MAX_AREA> The maximum size, in megabytes, for uploaded media
The maximum area, in pixels, for uploaded media --media-max-frame-count <MEDIA_MAX_FRAME_COUNT>
The maximum number of frames allowed for uploaded GIF and MP4s
--media-max-file-size <MEDIA_MAX_FILE_SIZE> --media-enable-silent-video <MEDIA_ENABLE_SILENT_VIDEO>
The maximum size, in megabytes, for uploaded media Whether to enable GIF and silent MP4 uploads [possible values: true, false]
--media-enable-full-video <MEDIA_ENABLE_FULL_VIDEO>
--media-max-height <MEDIA_MAX_HEIGHT> Whether to enable full MP4 uploads [possible values: true, false]
The maximum height, in pixels, for uploaded media --media-filters <MEDIA_FILTERS>
Which media filters should be enabled on the `process` endpoint
--media-max-width <MEDIA_MAX_WIDTH> --media-format <MEDIA_FORMAT>
The maximum width, in pixels, for uploaded media Enforce uploaded media is transcoded to the provided format [possible values: jpeg, webp, png]
--media-cache-duration <MEDIA_CACHE_DURATION>
--media-preprocess-steps <MEDIA_PREPROCESS_STEPS> How long, in hours, to keep media ingested through the "cached" endpoint
Optional pre-processing steps for uploaded media -h, --help
Print help information (use `--help` for more detail)
--media-skip-validate-imports <MEDIA_SKIP_VALIDATE_IMPORTS>
Whether to validate media on the "import" endpoint
--worker-id <WORKER_ID>
ID of this pict-rs node. Doesn't do much yet
SUBCOMMANDS:
filesystem Run pict-rs with filesystem storage
help Print this message or the help of the given subcommand(s)
object-storage Run pict-rs with object storage
``` ```
Try running `help` commands for more runtime configuration options Try running `help` commands for more runtime configuration options

View File

@ -333,45 +333,45 @@ struct Media {
/// Run the pict-rs application /// Run the pict-rs application
#[derive(Debug, Parser)] #[derive(Debug, Parser)]
#[clap(author, version, about, long_about = None)] #[command(author, version, about, long_about = None)]
pub(super) struct Args { pub(super) struct Args {
/// Path to the pict-rs configuration file /// Path to the pict-rs configuration file
#[clap(short, long)] #[arg(short, long)]
config_file: Option<PathBuf>, config_file: Option<PathBuf>,
/// Path to the old pict-rs sled database /// Path to the old pict-rs sled database
#[clap(long)] #[arg(long)]
old_db_path: Option<PathBuf>, old_db_path: Option<PathBuf>,
/// Format of logs printed to stdout /// Format of logs printed to stdout
#[clap(long)] #[arg(long)]
log_format: Option<LogFormat>, log_format: Option<LogFormat>,
/// Log levels to print to stdout, respects RUST_LOG formatting /// Log levels to print to stdout, respects RUST_LOG formatting
#[clap(long)] #[arg(long)]
log_targets: Option<Targets>, log_targets: Option<Targets>,
/// Address and port to expose tokio-console metrics /// Address and port to expose tokio-console metrics
#[clap(long)] #[arg(long)]
console_address: Option<SocketAddr>, console_address: Option<SocketAddr>,
/// Capacity of the console-subscriber Event Buffer /// Capacity of the console-subscriber Event Buffer
#[clap(long)] #[arg(long)]
console_buffer_capacity: Option<usize>, console_buffer_capacity: Option<usize>,
/// URL to send OpenTelemetry metrics /// URL to send OpenTelemetry metrics
#[clap(long)] #[arg(long)]
opentelemetry_url: Option<Url>, opentelemetry_url: Option<Url>,
/// Service Name to use for OpenTelemetry /// Service Name to use for OpenTelemetry
#[clap(long)] #[arg(long)]
opentelemetry_service_name: Option<String>, opentelemetry_service_name: Option<String>,
/// Log levels to use for OpenTelemetry, respects RUST_LOG formatting /// Log levels to use for OpenTelemetry, respects RUST_LOG formatting
#[clap(long)] #[arg(long)]
opentelemetry_targets: Option<Targets>, opentelemetry_targets: Option<Targets>,
/// File to save the current configuration for reproducible runs /// File to save the current configuration for reproducible runs
#[clap(long)] #[arg(long)]
save_to: Option<PathBuf>, save_to: Option<PathBuf>,
#[clap(subcommand)] #[command(subcommand)]
command: Command, command: Command,
} }
@ -381,66 +381,66 @@ enum Command {
Run(Run), Run(Run),
/// Migrates from one provided media store to another /// Migrates from one provided media store to another
#[clap(flatten)] #[command(flatten)]
MigrateStore(MigrateStore), MigrateStore(MigrateStore),
} }
#[derive(Debug, Parser)] #[derive(Debug, Parser)]
struct Run { struct Run {
/// The address and port to bind the pict-rs web server /// The address and port to bind the pict-rs web server
#[clap(short, long)] #[arg(short, long)]
address: Option<SocketAddr>, address: Option<SocketAddr>,
/// The API KEY required to access restricted routes /// The API KEY required to access restricted routes
#[clap(long)] #[arg(long)]
api_key: Option<String>, api_key: Option<String>,
/// ID of this pict-rs node. Doesn't do much yet /// ID of this pict-rs node. Doesn't do much yet
#[clap(long)] #[arg(long)]
worker_id: Option<String>, worker_id: Option<String>,
/// Optional pre-processing steps for uploaded media. /// Optional pre-processing steps for uploaded media.
/// ///
/// All still images will be put through these steps before saving /// All still images will be put through these steps before saving
#[clap(long)] #[arg(long)]
media_preprocess_steps: Option<String>, media_preprocess_steps: Option<String>,
/// Whether to validate media on the "import" endpoint /// Whether to validate media on the "import" endpoint
#[clap(long)] #[arg(long)]
media_skip_validate_imports: Option<bool>, media_skip_validate_imports: Option<bool>,
/// The maximum width, in pixels, for uploaded media /// The maximum width, in pixels, for uploaded media
#[clap(long)] #[arg(long)]
media_max_width: Option<usize>, media_max_width: Option<usize>,
/// The maximum height, in pixels, for uploaded media /// The maximum height, in pixels, for uploaded media
#[clap(long)] #[arg(long)]
media_max_height: Option<usize>, media_max_height: Option<usize>,
/// The maximum area, in pixels, for uploaded media /// The maximum area, in pixels, for uploaded media
#[clap(long)] #[arg(long)]
media_max_area: Option<usize>, media_max_area: Option<usize>,
/// The maximum size, in megabytes, for uploaded media /// The maximum size, in megabytes, for uploaded media
#[clap(long)] #[arg(long)]
media_max_file_size: Option<usize>, media_max_file_size: Option<usize>,
/// The maximum number of frames allowed for uploaded GIF and MP4s. /// The maximum number of frames allowed for uploaded GIF and MP4s.
#[clap(long)] #[arg(long)]
media_max_frame_count: Option<usize>, media_max_frame_count: Option<usize>,
/// Whether to enable GIF and silent MP4 uploads /// Whether to enable GIF and silent MP4 uploads
#[clap(long)] #[arg(long)]
media_enable_silent_video: Option<bool>, media_enable_silent_video: Option<bool>,
/// Whether to enable full MP4 uploads /// Whether to enable full MP4 uploads
#[clap(long)] #[arg(long)]
media_enable_full_video: Option<bool>, media_enable_full_video: Option<bool>,
/// Which media filters should be enabled on the `process` endpoint /// Which media filters should be enabled on the `process` endpoint
#[clap(long)] #[arg(long)]
media_filters: Option<Vec<String>>, media_filters: Option<Vec<String>>,
/// Enforce uploaded media is transcoded to the provided format /// Enforce uploaded media is transcoded to the provided format
#[clap(long)] #[arg(long)]
media_format: Option<ImageFormat>, media_format: Option<ImageFormat>,
/// How long, in hours, to keep media ingested through the "cached" endpoint /// How long, in hours, to keep media ingested through the "cached" endpoint
#[clap(long)] #[arg(long)]
media_cache_duration: Option<i64>, media_cache_duration: Option<i64>,
#[clap(subcommand)] #[command(subcommand)]
store: Option<RunStore>, store: Option<RunStore>,
} }
@ -489,60 +489,60 @@ enum MigrateStoreInner {
/// Migrate pict-rs' storage from the provided filesystem storage /// Migrate pict-rs' storage from the provided filesystem storage
#[derive(Debug, Parser)] #[derive(Debug, Parser)]
struct MigrateFilesystem { struct MigrateFilesystem {
#[clap(flatten)] #[command(flatten)]
from: crate::config::primitives::Filesystem, from: crate::config::primitives::Filesystem,
#[clap(subcommand)] #[command(subcommand)]
to: MigrateStoreInner, to: MigrateStoreInner,
} }
/// Migrate pict-rs' storage to the provided filesystem storage /// Migrate pict-rs' storage to the provided filesystem storage
#[derive(Debug, Parser)] #[derive(Debug, Parser)]
struct MigrateFilesystemInner { struct MigrateFilesystemInner {
#[clap(flatten)] #[command(flatten)]
to: crate::config::primitives::Filesystem, to: crate::config::primitives::Filesystem,
#[clap(subcommand)] #[command(subcommand)]
repo: Option<Repo>, repo: Option<Repo>,
} }
/// Migrate pict-rs' storage from the provided object storage /// Migrate pict-rs' storage from the provided object storage
#[derive(Debug, Parser)] #[derive(Debug, Parser)]
struct MigrateObjectStorage { struct MigrateObjectStorage {
#[clap(flatten)] #[command(flatten)]
from: crate::config::primitives::ObjectStorage, from: crate::config::primitives::ObjectStorage,
#[clap(subcommand)] #[command(subcommand)]
to: MigrateStoreInner, to: MigrateStoreInner,
} }
/// Migrate pict-rs' storage to the provided object storage /// Migrate pict-rs' storage to the provided object storage
#[derive(Debug, Parser)] #[derive(Debug, Parser)]
struct MigrateObjectStorageInner { struct MigrateObjectStorageInner {
#[clap(flatten)] #[command(flatten)]
to: crate::config::primitives::ObjectStorage, to: crate::config::primitives::ObjectStorage,
#[clap(subcommand)] #[command(subcommand)]
repo: Option<Repo>, repo: Option<Repo>,
} }
/// Run pict-rs with the provided filesystem storage /// Run pict-rs with the provided filesystem storage
#[derive(Debug, Parser)] #[derive(Debug, Parser)]
struct RunFilesystem { struct RunFilesystem {
#[clap(flatten)] #[command(flatten)]
system: Filesystem, system: Filesystem,
#[clap(subcommand)] #[command(subcommand)]
repo: Option<Repo>, repo: Option<Repo>,
} }
/// Run pict-rs with the provided object storage /// Run pict-rs with the provided object storage
#[derive(Debug, Parser)] #[derive(Debug, Parser)]
struct RunObjectStorage { struct RunObjectStorage {
#[clap(flatten)] #[command(flatten)]
storage: ObjectStorage, storage: ObjectStorage,
#[clap(subcommand)] #[command(subcommand)]
repo: Option<Repo>, repo: Option<Repo>,
} }
@ -560,7 +560,7 @@ enum Repo {
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
struct Filesystem { struct Filesystem {
/// The path to store uploaded media /// The path to store uploaded media
#[clap(short, long)] #[arg(short, long)]
path: Option<PathBuf>, path: Option<PathBuf>,
} }
@ -573,36 +573,36 @@ struct ObjectStorage {
/// Examples: /// Examples:
/// - `http://localhost:9000` /// - `http://localhost:9000`
/// - `https://s3.dualstack.eu-west-1.amazonaws.com` /// - `https://s3.dualstack.eu-west-1.amazonaws.com`
#[clap(short, long)] #[arg(short, long)]
endpoint: Url, endpoint: Url,
/// Determines whether to use path style or virtualhost style for accessing objects /// Determines whether to use path style or virtualhost style for accessing objects
/// ///
/// When this is true, objects will be fetched from {endpoint}/{bucket_name}/{object} /// When this is true, objects will be fetched from {endpoint}/{bucket_name}/{object}
/// When false, objects will be fetched from {bucket_name}.{endpoint}/{object} /// When false, objects will be fetched from {bucket_name}.{endpoint}/{object}
#[clap(short, long)] #[arg(short, long)]
use_path_style: bool, use_path_style: bool,
/// The bucket in which to store media /// The bucket in which to store media
#[clap(short, long)] #[arg(short, long)]
bucket_name: Option<String>, bucket_name: Option<String>,
/// The region the bucket is located in /// The region the bucket is located in
/// ///
/// For minio deployments, this can just be 'minio' /// For minio deployments, this can just be 'minio'
#[clap(short, long)] #[arg(short, long)]
region: Option<String>, region: Option<String>,
/// The Access Key for the user accessing the bucket /// The Access Key for the user accessing the bucket
#[clap(short, long)] #[arg(short, long)]
access_key: Option<String>, access_key: Option<String>,
/// The secret key for the user accessing the bucket /// The secret key for the user accessing the bucket
#[clap(short, long)] #[arg(short, long)]
secret_key: Option<String>, secret_key: Option<String>,
/// The session token for accessing the bucket /// The session token for accessing the bucket
#[clap(long)] #[arg(long)]
session_token: Option<String>, session_token: Option<String>,
} }
@ -611,12 +611,12 @@ struct ObjectStorage {
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
struct Sled { struct Sled {
/// The path to store the sled database /// The path to store the sled database
#[clap(short, long)] #[arg(short, long)]
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
path: Option<PathBuf>, path: Option<PathBuf>,
/// The cache capacity, in bytes, allowed to sled for in-memory operations /// The cache capacity, in bytes, allowed to sled for in-memory operations
#[clap(short, long)] #[arg(short, long)]
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
cache_capacity: Option<u64>, cache_capacity: Option<u64>,
} }

View File

@ -1,5 +1,5 @@
use crate::magick::ValidInputType; use crate::magick::ValidInputType;
use clap::ArgEnum; use clap::ValueEnum;
use std::{fmt::Display, path::PathBuf, str::FromStr}; use std::{fmt::Display, path::PathBuf, str::FromStr};
use tracing::Level; use tracing::Level;
use url::Url; use url::Url;
@ -15,7 +15,7 @@ use url::Url;
Hash, Hash,
serde::Deserialize, serde::Deserialize,
serde::Serialize, serde::Serialize,
ArgEnum, ValueEnum,
)] )]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub(crate) enum LogFormat { pub(crate) enum LogFormat {
@ -36,7 +36,7 @@ pub(crate) enum LogFormat {
Hash, Hash,
serde::Deserialize, serde::Deserialize,
serde::Serialize, serde::Serialize,
ArgEnum, ValueEnum,
)] )]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub(crate) enum ImageFormat { pub(crate) enum ImageFormat {
@ -55,7 +55,7 @@ pub(crate) struct Targets {
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub(crate) struct Filesystem { pub(crate) struct Filesystem {
/// Path to store media /// Path to store media
#[clap(short, long)] #[arg(short, long)]
pub(crate) path: PathBuf, pub(crate) path: PathBuf,
} }
@ -68,34 +68,34 @@ pub(crate) struct ObjectStorage {
/// Examples: /// Examples:
/// - `http://localhost:9000` /// - `http://localhost:9000`
/// - `https://s3.dualstack.eu-west-1.amazonaws.com` /// - `https://s3.dualstack.eu-west-1.amazonaws.com`
#[clap(short, long)] #[arg(short, long)]
pub(crate) endpoint: Url, pub(crate) endpoint: Url,
/// Determines whether to use path style or virtualhost style for accessing objects /// Determines whether to use path style or virtualhost style for accessing objects
/// ///
/// When this is true, objects will be fetched from {endpoint}/{bucket_name}/{object} /// When this is true, objects will be fetched from {endpoint}/{bucket_name}/{object}
/// When false, objects will be fetched from {bucket_name}.{endpoint}/{object} /// When false, objects will be fetched from {bucket_name}.{endpoint}/{object}
#[clap(short, long)] #[arg(short, long)]
pub(crate) use_path_style: bool, pub(crate) use_path_style: bool,
/// The bucket in which to store media /// The bucket in which to store media
#[clap(short, long)] #[arg(short, long)]
pub(crate) bucket_name: String, pub(crate) bucket_name: String,
/// The region the bucket is located in /// The region the bucket is located in
#[clap(short, long)] #[arg(short, long)]
pub(crate) region: String, pub(crate) region: String,
/// The Access Key for the user accessing the bucket /// The Access Key for the user accessing the bucket
#[clap(short, long)] #[arg(short, long)]
pub(crate) access_key: String, pub(crate) access_key: String,
/// The secret key for the user accessing the bucket /// The secret key for the user accessing the bucket
#[clap(short, long)] #[arg(short, long)]
pub(crate) secret_key: String, pub(crate) secret_key: String,
/// The session token for accessing the bucket /// The session token for accessing the bucket
#[clap(long)] #[arg(long)]
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub(crate) session_token: Option<String>, pub(crate) session_token: Option<String>,
} }