1use std::path::PathBuf;
2
3use clap::{Parser, ValueEnum};
4
5use crate::cmd::download::{Format, PngSize};
6
7#[derive(Clone, Debug)]
8pub enum Sorting {
9 Default,
10 AZ,
11 Downloads,
12 Newest,
13}
14
15impl ValueEnum for Sorting {
16 fn value_variants<'a>() -> &'a [Self] {
17 &[Self::Default, Self::AZ, Self::Downloads, Self::Newest]
18 }
19
20 fn to_possible_value(&self) -> Option<clap::builder::PossibleValue> {
21 Some(match self {
22 Sorting::Default => clap::builder::PossibleValue::new("default"),
23 Sorting::AZ => clap::builder::PossibleValue::new("az"),
24 Sorting::Downloads => clap::builder::PossibleValue::new("downloads"),
25 Sorting::Newest => clap::builder::PossibleValue::new("newest"),
26 })
27 }
28}
29
30impl ToString for Sorting {
31 fn to_string(&self) -> String {
32 match self {
33 Sorting::Default => "default".to_string(),
34 Sorting::AZ => "alphabetical".to_string(),
35 Sorting::Downloads => "downloads".to_string(),
36 Sorting::Newest => "newest".to_string(),
37 }
38 }
39}
40
41#[derive(Debug, Parser)]
42pub enum Cli {
43 #[command(about = "Search for color palettes")]
44 Search {
45 #[arg(long, conflicts_with_all = ["min", "exact"])]
47 max: Option<u16>,
48
49 #[arg(long, conflicts_with_all = ["max", "exact"])]
51 min: Option<u16>,
52
53 #[arg(long, conflicts_with_all = ["max", "min"])]
55 exact: Option<u16>,
56
57 #[arg(short, long)]
59 page: Option<u16>, #[arg(long, default_value_t = Sorting::Default)]
63 sorting: Sorting,
64
65 #[arg(long)]
67 tag: Option<String>, },
69 #[command(about = "Download a color palette")]
70 Download {
71 slug: String,
73
74 #[arg(short, long)]
76 path: Option<PathBuf>,
77
78 #[arg(short, long)]
80 format: Format,
81
82 #[arg(short, long)]
84 size: Option<PngSize>,
85 },
86}