Last active
March 28, 2023 18:40
-
-
Save TheBestTvarynka/962ca225a28782e6b066750129121ef6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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