File tree Expand file tree Collapse file tree 5 files changed +30
-31
lines changed
third-party/watchman/src/watchman/rust/watchman_client Expand file tree Collapse file tree 5 files changed +30
-31
lines changed Original file line number Diff line number Diff line change @@ -20,8 +20,8 @@ thiserror = "1.0"
2020tokio = { version = " 1.7.1" , features = [" full" , " test-util" ] }
2121tokio-util = { version = " 0.6" , features = [" full" ] }
2222
23- [dev-dependencies ]
24- structopt = " 0.3"
25-
2623[target .'cfg(windows)' .dependencies ]
2724winapi = { version = " 0.3" , features = [" handleapi" , " winuser" ] }
25+
26+ [dev-dependencies ]
27+ clap = { version = " 4.5.7" , features = [" derive" ] }
Original file line number Diff line number Diff line change 77
88use std:: path:: PathBuf ;
99
10+ use clap:: Parser ;
1011use serde:: Deserialize ;
11- use structopt:: StructOpt ;
1212use watchman_client:: prelude:: * ;
1313
14- # [ derive ( Debug , StructOpt ) ]
15- #[ structopt ( about = "Perform a glob query for a path, using watchman" ) ]
16- struct Opt {
17- #[ structopt ( default_value = "." ) ]
14+ /// Perform a glob query for a path, using watchman
15+ #[ derive ( Debug , Parser ) ]
16+ struct Cli {
17+ #[ arg ( default_value = "." ) ]
1818 path : PathBuf ,
1919}
2020
@@ -29,7 +29,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
2929}
3030
3131async fn run ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
32- let opt = Opt :: from_args ( ) ;
32+ let opt = Cli :: parse ( ) ;
3333 let client = Connector :: new ( ) . connect ( ) . await ?;
3434 let resolved = client
3535 . resolve_root ( CanonicalPath :: canonicalize ( opt. path ) ?)
Original file line number Diff line number Diff line change 1010
1111use std:: path:: PathBuf ;
1212
13- use structopt :: StructOpt ;
13+ use clap :: Parser ;
1414use watchman_client:: prelude:: * ;
1515
16- #[ derive( Debug , StructOpt ) ]
17- #[ structopt( about = "Query files changed since a timestamp" ) ]
18- struct Opt {
19- #[ structopt( ) ]
20- /// Specifies the clock. Use `watchman clock <PATH>` to retrieve the current clock of a watched
21- /// directory
16+ /// Query files changed since a timestamp
17+ #[ derive( Debug , Parser ) ]
18+ struct Cli {
19+ /// Specifies the clock. Use `watchman clock <PATH>` to retrieve the current
20+ /// clock of a watched directory
2221 clock : String ,
2322
24- #[ structopt ( short, long) ]
23+ #[ arg ( short, long) ]
2524 /// [not recommended] Uses Unix timestamp as clock
2625 unix_timestamp : bool ,
2726
28- #[ structopt ( short, long, default_value = "." ) ]
27+ #[ arg ( short, long, default_value = "." ) ]
2928 /// Specifies the path to watched directory
3029 path : PathBuf ,
3130}
@@ -41,7 +40,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
4140}
4241
4342async fn run ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
44- let opt = Opt :: from_args ( ) ;
43+ let opt = Cli :: parse ( ) ;
4544 let client = Connector :: new ( ) . connect ( ) . await ?;
4645 let resolved = client
4746 . resolve_root ( CanonicalPath :: canonicalize ( opt. path ) ?)
Original file line number Diff line number Diff line change 77
88use std:: path:: PathBuf ;
99
10- use structopt :: StructOpt ;
10+ use clap :: Parser ;
1111use watchman_client:: prelude:: * ;
1212
13- # [ derive ( Debug , StructOpt ) ]
14- #[ structopt ( about = "Exercise the state-enter and state-leave commands" ) ]
15- struct Opt {
16- #[ structopt ( default_value = "." ) ]
13+ /// Exercise the state-enter and state-leave commands
14+ #[ derive ( Debug , Parser ) ]
15+ struct Cli {
16+ #[ arg ( default_value = "." ) ]
1717 path : PathBuf ,
1818}
1919
@@ -28,7 +28,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
2828}
2929
3030async fn run ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
31- let opt = Opt :: from_args ( ) ;
31+ let opt = Cli :: parse ( ) ;
3232 let client = Connector :: new ( ) . connect ( ) . await ?;
3333 let resolved = client
3434 . resolve_root ( CanonicalPath :: canonicalize ( opt. path ) ?)
Original file line number Diff line number Diff line change 99//! file changes as they are reported
1010use std:: path:: PathBuf ;
1111
12- use structopt :: StructOpt ;
12+ use clap :: Parser ;
1313use watchman_client:: prelude:: * ;
1414
15- # [ derive ( Debug , StructOpt ) ]
16- #[ structopt ( about = "Subscribe to watchman and stream file changes for a path" ) ]
17- struct Opt {
18- #[ structopt ( default_value = "." ) ]
15+ /// Subscribe to watchman and stream file changes for a path
16+ #[ derive ( Debug , Parser ) ]
17+ struct Cli {
18+ #[ arg ( default_value = "." ) ]
1919 path : PathBuf ,
2020}
2121
@@ -29,7 +29,7 @@ async fn main() {
2929}
3030
3131async fn run ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
32- let opt = Opt :: from_args ( ) ;
32+ let opt = Cli :: parse ( ) ;
3333 let client = Connector :: new ( ) . connect ( ) . await ?;
3434 let resolved = client
3535 . resolve_root ( CanonicalPath :: canonicalize ( opt. path ) ?)
You can’t perform that action at this time.
0 commit comments