Skip to main content

upstream_rs/application/cli/
labels.rs

1use std::fmt;
2
3use crate::application::cli::arguments::{
4    Commands, ConfigAction, HooksAction, PackageAction, RollbackAction,
5};
6
7impl fmt::Display for Commands {
8    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
9        match self {
10            Commands::Install { .. } => write!(f, "install"),
11            Commands::Build { .. } => write!(f, "build"),
12            Commands::Remove { .. } => write!(f, "remove"),
13            Commands::Rollback { action } => write!(f, "{action}"),
14            Commands::Reinstall { .. } => write!(f, "reinstall"),
15            Commands::Upgrade { .. } => write!(f, "upgrade"),
16            Commands::List { .. } => write!(f, "list"),
17            Commands::Changelog { .. } => write!(f, "changelog"),
18            Commands::Probe { .. } => write!(f, "probe"),
19            Commands::Search { .. } => write!(f, "search"),
20            Commands::Find { .. } => write!(f, "find"),
21            Commands::Config { action } => write!(f, "{action}"),
22            Commands::Package { action } => write!(f, "{action}"),
23            Commands::Hooks { action } => write!(f, "{action}"),
24            Commands::Import { .. } => write!(f, "import"),
25            Commands::Export { .. } => write!(f, "export"),
26            Commands::Migrate => write!(f, "migrate"),
27            Commands::Doctor { .. } => write!(f, "doctor"),
28        }
29    }
30}
31
32impl fmt::Display for ConfigAction {
33    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
34        match self {
35            ConfigAction::Set { .. } => write!(f, "config set"),
36            ConfigAction::Get { .. } => write!(f, "config get"),
37            ConfigAction::List => write!(f, "config list"),
38            ConfigAction::Edit => write!(f, "config edit"),
39            ConfigAction::Reset => write!(f, "config reset"),
40        }
41    }
42}
43
44impl fmt::Display for HooksAction {
45    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
46        match self {
47            HooksAction::Init => write!(f, "hooks init"),
48            HooksAction::Check => write!(f, "hooks check"),
49            HooksAction::Clean => write!(f, "hooks clean"),
50            HooksAction::Purge => write!(f, "hooks purge"),
51        }
52    }
53}
54
55impl fmt::Display for PackageAction {
56    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
57        match self {
58            PackageAction::Pin { .. } => write!(f, "package pin"),
59            PackageAction::Unpin { .. } => write!(f, "package unpin"),
60            PackageAction::Rename { .. } => write!(f, "package rename"),
61        }
62    }
63}
64
65impl fmt::Display for RollbackAction {
66    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
67        match self {
68            RollbackAction::Restore { .. } => write!(f, "rollback restore"),
69            RollbackAction::Prune { .. } => write!(f, "rollback prune"),
70            RollbackAction::List => write!(f, "rollback list"),
71        }
72    }
73}