Skip to content

Instantly share code, notes, and snippets.

@TheBestTvarynka
Last active March 28, 2023 18:40
Show Gist options
  • Save TheBestTvarynka/962ca225a28782e6b066750129121ef6 to your computer and use it in GitHub Desktop.
Save TheBestTvarynka/962ca225a28782e6b066750129121ef6 to your computer and use it in GitHub Desktop.
use std::str::FromStr;
#[derive(Debug)]
pub struct TokenInfo {
pub a: String,
pub b: String
}
impl FromStr for TokenInfo {
type Err = std::io::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let mut i = s.split(":");
Ok(Self {
a: i.next().unwrap().to_owned(),
b: i.next().unwrap().to_owned(),
})
}
}
#[argopt::cmd]
fn main(
/// Command.
command: String,
/// Command value.
value: String,
/// Migrate options. Format: "a:b".
#[opt(short = 'm', long = "migrate")]
migrate: TokenInfo,
) {
println!("command: {command}");
println!("value: {value}");
println!("migrate: {:?}", migrate);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment