1414
1515use anyhow:: { ensure, Context as _} ;
1616use chrono:: Local ;
17+ use clap:: Parser ;
1718use serde:: Serialize ;
1819use std:: fs:: File ;
1920use std:: io:: { BufWriter , Read as _, Write as _} ;
2021use std:: path:: { Component , Path , PathBuf } ;
21- use structopt:: clap:: arg_enum;
22- use structopt:: StructOpt ;
2322use url:: Url ;
2423use webbundle:: { Bundle , Result , Version } ;
2524
26- #[ derive( StructOpt ) ]
25+ #[ derive( Parser ) ]
2726struct Cli {
28- #[ structopt ( subcommand) ]
27+ #[ clap ( subcommand) ]
2928 cmd : Command ,
3029}
3130
32- arg_enum ! {
33- #[ allow( non_camel_case_types) ]
34- pub enum Format {
35- plain,
36- json,
37- debug,
38- }
31+ #[ derive( Parser , Clone , clap:: ValueEnum ) ]
32+ enum Format {
33+ Plain ,
34+ Json ,
35+ Debug ,
3936}
4037
41- #[ derive( StructOpt ) ]
38+ #[ derive( Parser ) ]
4239enum Command {
4340 //github.com/ Example: webbundle create example.wbn foo
44- #[ structopt( name = "create" ) ]
4541 Create {
46- #[ structopt ( short = "p" , long = "primary-url" ) ]
42+ #[ arg ( short = 'p' , long) ]
4743 primary_url : Option < String > ,
4844 //github.com/ File name
4945 file : String ,
@@ -52,14 +48,12 @@ enum Command {
5248 // TODO: Support version
5349 } ,
5450 //github.com/ List the contents briefly
55- #[ structopt( name = "list" ) ]
5651 List {
5752 file : String ,
58- #[ structopt ( long = "format" , possible_values ( & Format :: variants ( ) ) ) ]
53+ #[ arg ( long, value_enum ) ]
5954 format : Option < Format > ,
6055 } ,
6156 //github.com/ Extract the contents
62- #[ structopt( name = "extract" ) ]
6357 Extract { file : String } ,
6458}
6559
@@ -82,9 +76,9 @@ fn env_logger_init() {
8276
8377fn list ( bundle : & Bundle , format : Option < Format > ) {
8478 match format {
85- None | Some ( Format :: plain ) => list_plain ( bundle) ,
86- Some ( Format :: json ) => list_json ( bundle) ,
87- Some ( Format :: debug ) => list_debug ( bundle) ,
79+ None | Some ( Format :: Plain ) => list_plain ( bundle) ,
80+ Some ( Format :: Json ) => list_json ( bundle) ,
81+ Some ( Format :: Debug ) => list_debug ( bundle) ,
8882 }
8983}
9084
@@ -270,7 +264,7 @@ fn extract(bundle: &Bundle) -> Result<()> {
270264#[ tokio:: main]
271265async fn main ( ) -> Result < ( ) > {
272266 env_logger_init ( ) ;
273- let args = Cli :: from_args ( ) ;
267+ let args = Cli :: parse ( ) ;
274268 match args. cmd {
275269 Command :: Create {
276270 primary_url,
0 commit comments