@@ -3,38 +3,38 @@ use std::io::{self, Read, Write};
33use std:: str:: FromStr ;
44
55use anyhow:: { anyhow, Error , Result } ;
6+ use clap:: { Parser , Subcommand } ;
67use multibase:: Base ;
7- use structopt:: StructOpt ;
88
9- #[ derive( StructOpt , Debug ) ]
9+ #[ derive( Parser , Debug ) ]
1010struct Opts {
1111 /// The mode
12- #[ structopt ( subcommand) ]
12+ #[ command ( subcommand) ]
1313 mode : Mode ,
1414}
1515
16- #[ derive( StructOpt , Debug ) ]
16+ #[ derive( Subcommand , Debug ) ]
1717enum Mode {
18- #[ structopt ( name = "encode" ) ]
18+ #[ command ( name = "encode" ) ]
1919 Encode {
2020 /// The base to use for encoding.
21- #[ structopt ( short = "b" , long = "base" , default_value = "base58btc" ) ]
21+ #[ arg ( short = 'b' , long = "base" , default_value = "base58btc" ) ]
2222 base : StrBase ,
2323 /// The data to encode. Reads from stdin if not provided.
24- #[ structopt ( short = "i" , long = "input" ) ]
24+ #[ arg ( short = 'i' , long = "input" ) ]
2525 input : Option < String > ,
2626 } ,
27- #[ structopt ( name = "decode" ) ]
27+ #[ command ( name = "decode" ) ]
2828 Decode {
2929 /// The data to decode. Reads from stdin if not provided.
30- #[ structopt ( short = "i" , long = "input" ) ]
30+ #[ arg ( short = 'i' , long = "input" ) ]
3131 input : Option < String > ,
3232 } ,
3333}
3434
3535fn main ( ) -> Result < ( ) > {
3636 env_logger:: init ( ) ;
37- let opts = Opts :: from_args ( ) ;
37+ let opts = Opts :: parse ( ) ;
3838 match opts. mode {
3939 Mode :: Encode { base, input } => {
4040 let input_bytes = match input {
@@ -61,7 +61,7 @@ fn main() -> Result<()> {
6161 }
6262}
6363
64- #[ derive( Debug ) ]
64+ #[ derive( Debug , Clone ) ]
6565struct StrBase ( Base ) ;
6666
6767impl fmt:: Display for StrBase {
0 commit comments