Skip to main content

img_squeeze/
cli.rs

1use clap::{Parser, Subcommand};
2use std::path::PathBuf;
3
4#[derive(Parser)]
5#[command(
6    name = "img-squeeze",
7    about = "A Rust-based image compression tool",
8    version = "0.1.1"
9)]
10pub struct Args {
11    #[command(subcommand)]
12    pub command: Commands,
13}
14
15#[derive(Subcommand)]
16pub enum Commands {
17    #[command(about = "Compress an image")]
18    Compress {
19        #[arg(help = "Input image file")]
20        input: PathBuf,
21
22        #[arg(help = "Output image file")]
23        output: PathBuf,
24
25        #[arg(short = 'q', long, help = "Quality (1-100), default is 80")]
26        quality: Option<u8>,
27
28        #[arg(short = 'w', long, help = "Maximum width in pixels")]
29        width: Option<u32>,
30
31        #[arg(short = 'H', long, help = "Maximum height in pixels")]
32        height: Option<u32>,
33
34        #[arg(
35            short = 'f',
36            long,
37            value_parser = ["jpeg","jpg","png","webp","avif"],
38            value_name = "FORMAT",
39            help = "Output format (jpeg, jpg, png, webp, avif). Note: heic/heif/jxl are recognized as inputs only."
40        )]
41        format: Option<String>,
42
43        #[arg(short = 'j', long, help = "Number of parallel threads (default: auto)")]
44        threads: Option<usize>,
45    },
46
47    #[command(about = "Compress multiple images in parallel")]
48    Batch {
49        #[arg(help = "Input directory or file pattern")]
50        input: String,
51
52        #[arg(help = "Output directory")]
53        output: PathBuf,
54
55        #[arg(short = 'q', long, help = "Quality (1-100), default is 80")]
56        quality: Option<u8>,
57
58        #[arg(short = 'w', long, help = "Maximum width in pixels")]
59        width: Option<u32>,
60
61        #[arg(short = 'H', long, help = "Maximum height in pixels")]
62        height: Option<u32>,
63
64        #[arg(
65            short = 'f',
66            long,
67            value_parser = ["jpeg","jpg","png","webp","avif"],
68            value_name = "FORMAT",
69            help = "Output format (jpeg, jpg, png, webp, avif). Note: heic/heif/jxl are recognized as inputs only."
70        )]
71        format: Option<String>,
72
73        #[arg(short = 'j', long, help = "Number of parallel threads (default: auto)")]
74        threads: Option<usize>,
75
76        #[arg(short = 'r', long, help = "Recursive directory processing")]
77        recursive: bool,
78    },
79
80    #[command(about = "Upload an image to Walrus storage")]
81    Upload {
82        #[arg(help = "Image file to upload")]
83        input: PathBuf,
84
85        #[arg(short = 'a', long, help = "Walrus aggregator URL")]
86        aggregator_url: Option<String>,
87
88        #[arg(short = 'p', long, help = "Walrus publisher URL")]
89        publisher_url: Option<String>,
90
91        #[arg(short = 'e', long, help = "Number of epochs for storage")]
92        epochs: Option<u64>,
93
94        #[arg(short = 't', long, help = "Upload as temporary file (1 epoch storage)")]
95        temp: bool,
96    },
97
98    #[command(about = "Get information about an image")]
99    Info {
100        #[arg(help = "Image file to analyze")]
101        input: PathBuf,
102    },
103}