Debian Codegraph @

src/cli.rs

raw
1 use std::path::PathBuf;
2
3 use gio::prelude::*;
4
5 #[derive(Debug, clap::Parser)]
6 #[command(version, about)]
7 pub struct Args {
8 #[clap(flatten)]
9 pub source: Source,
10 #[clap(short, long)]
11 /// Path under which to output the thumbnail as PNG
12 pub output: PathBuf,
13 #[clap(short, long)]
14 /// Maximum size for width and height of the thumbnail
15 pub size: u16,
16 }
17
18 #[derive(Debug, clap::Args)]
19 #[group(required = true, multiple = false)]
20 pub struct Source {
21 /// URI of file to create the thumbnail for
22 #[clap(short, long)]
23 pub input_uri: Option<String>,
24 /// Path of the file to create the thumbnail for
25 #[clap(short = 'p', long)]
26 pub input_path: Option<PathBuf>,
27 }
28
29 impl Source {
30 pub fn uri(&self) -> String {
31 self.input_uri.clone().unwrap_or_else(|| {
32 gio::File::for_path(self.input_path.clone().unwrap())
33 .uri()
34 .to_string()
35 })
36 }
37 }