version_manager/cli/getset/
ver.rs1use crate::{VersionError, version::Operator};
2use clap::{Parser, builder::NonEmptyStringValueParser};
3
4#[derive(Parser, Debug, Clone, PartialEq)]
5#[command(arg_required_else_help(true))]
7pub struct SetVer {
8 #[arg(value_parser = NonEmptyStringValueParser::new())]
9 pub val: String,
10}
11
12impl TryFrom<SetVer> for Operator {
13 type Error = VersionError;
14
15 fn try_from(cmd: SetVer) -> Result<Self, Self::Error> {
16 Ok(Operator::SetVersion(cmd.val))
17 }
18}
19
20impl TryFrom<&SetVer> for Operator {
21 type Error = VersionError;
22
23 fn try_from(cmd: &SetVer) -> Result<Self, Self::Error> {
24 Ok(Operator::SetVersion(cmd.val.clone()))
25 }
26}