@@ -8,6 +8,7 @@ use cratesfyi::{BuildQueue, Config, DocBuilder, DocBuilderOptions, RustwideBuild
8
8
use failure:: Error ;
9
9
use once_cell:: sync:: OnceCell ;
10
10
use structopt:: StructOpt ;
11
+ use strum:: VariantNames ;
11
12
12
13
pub fn main ( ) -> Result < ( ) , Error > {
13
14
let _ = dotenv:: dotenv ( ) ;
@@ -40,6 +41,13 @@ fn logger_init() {
40
41
rustwide:: logging:: init_with ( builder. build ( ) ) ;
41
42
}
42
43
44
+ #[ derive( Debug , Clone , Copy , PartialEq , Eq , strum:: EnumString , strum:: EnumVariantNames ) ]
45
+ #[ strum( serialize_all = "snake_case" ) ]
46
+ enum Toggle {
47
+ Enabled ,
48
+ Disabled ,
49
+ }
50
+
43
51
#[ derive( Debug , Clone , PartialEq , Eq , StructOpt ) ]
44
52
#[ structopt(
45
53
name = "cratesfyi" ,
@@ -66,8 +74,13 @@ enum CommandLine {
66
74
#[ structopt( name = "FOREGROUND" , short = "f" , long = "foreground" ) ]
67
75
foreground : bool ,
68
76
69
- #[ structopt( long = "disable-registry-watcher" ) ]
70
- disable_registry_watcher : bool ,
77
+ /// Enable or disable the registry watcher to automatically enqueue newly published crates
78
+ #[ structopt(
79
+ long = "registry-watcher" ,
80
+ default_value = "enabled" ,
81
+ possible_values( Toggle :: VARIANTS )
82
+ ) ]
83
+ registry_watcher : Toggle ,
71
84
} ,
72
85
73
86
/// Database operations
@@ -103,7 +116,7 @@ impl CommandLine {
103
116
}
104
117
Self :: Daemon {
105
118
foreground,
106
- disable_registry_watcher ,
119
+ registry_watcher ,
107
120
} => {
108
121
if foreground {
109
122
log:: warn!( "--foreground was passed, but there is no need for it anymore" ) ;
@@ -113,7 +126,7 @@ impl CommandLine {
113
126
ctx. config ( ) ?,
114
127
ctx. pool ( ) ?,
115
128
ctx. build_queue ( ) ?,
116
- !disable_registry_watcher ,
129
+ registry_watcher == Toggle :: Enabled ,
117
130
) ?;
118
131
}
119
132
Self :: Database { subcommand } => subcommand. handle_args ( ctx) ?,
0 commit comments