version_manager/cli/getset/
rm.rs1use super::Set;
2use crate::{VersionError, version::Operator};
3use clap::{Parser, Subcommand};
4
5#[derive(Parser, Debug, Clone, PartialEq)]
6#[command(arg_required_else_help(true))]
8pub struct GetSetRm {
9 #[command(subcommand)]
10 pub command: GetSetRmCommand,
11}
12
13impl TryFrom<GetSetRm> for Operator {
14 type Error = VersionError;
15
16 fn try_from(cmd: GetSetRm) -> Result<Self, Self::Error> {
17 cmd.command.try_into()
18 }
19}
20
21impl TryFrom<&GetSetRm> for Operator {
22 type Error = VersionError;
23
24 fn try_from(cmd: &GetSetRm) -> Result<Self, Self::Error> {
25 (&cmd.command).try_into()
26 }
27}
28
29#[derive(Subcommand, Debug, Clone, PartialEq)]
30pub enum GetSetRmCommand {
32 Get,
34 Set(Set),
36 Rm,
38 Reset,
40}
41
42impl TryFrom<&GetSetRmCommand> for Operator {
43 type Error = VersionError;
44
45 fn try_from(cmd: &GetSetRmCommand) -> Result<Self, Self::Error> {
46 match cmd {
47 GetSetRmCommand::Get => Ok(Operator::Get),
48 GetSetRmCommand::Set(set) => Ok(Operator::Set(set.try_into()?)),
49 GetSetRmCommand::Rm => Ok(Operator::Rm),
50 GetSetRmCommand::Reset => Ok(Operator::Reset),
51 }
52 }
53}
54
55impl TryFrom<GetSetRmCommand> for Operator {
56 type Error = VersionError;
57
58 fn try_from(cmd: GetSetRmCommand) -> Result<Self, Self::Error> {
59 match cmd {
60 GetSetRmCommand::Get => Ok(Operator::Get),
61 GetSetRmCommand::Set(set) => Ok(Operator::Set(set.try_into()?)),
62 GetSetRmCommand::Rm => Ok(Operator::Rm),
63 GetSetRmCommand::Reset => Ok(Operator::Reset),
64 }
65 }
66}