Skip to content

Commit 914e365

Browse files
Nemo157Joshua Nelson
authored and
Joshua Nelson
committed
Make registry-watcher flag a enable/disable toggle
1 parent 73566d0 commit 914e365

File tree

4 files changed

+41
-5
lines changed

4 files changed

+41
-5
lines changed

Cargo.lock

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ git2 = { version = "0.13.6", default-features = false }
4545
path-slash = "0.1.3"
4646
once_cell = { version = "1.4.0", features = ["parking_lot"] }
4747
base64 = "0.12.1"
48+
strum = { version = "0.18.0", features = ["derive"] }
4849

4950
# Data serialization and deserialization
5051
serde = { version = "1.0", features = ["derive"] }

dockerfiles/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,4 @@ COPY dockerfiles/entrypoint.sh /opt/docsrs/
7979

8080
WORKDIR /opt/docsrs
8181
ENTRYPOINT ["/opt/docsrs/entrypoint.sh"]
82-
CMD ["daemon", "--disable-registry-watcher"]
82+
CMD ["daemon", "--registry-watcher=disabled"]

src/bin/cratesfyi.rs

+17-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use cratesfyi::{BuildQueue, Config, DocBuilder, DocBuilderOptions, RustwideBuild
88
use failure::Error;
99
use once_cell::sync::OnceCell;
1010
use structopt::StructOpt;
11+
use strum::VariantNames;
1112

1213
pub fn main() -> Result<(), Error> {
1314
let _ = dotenv::dotenv();
@@ -40,6 +41,13 @@ fn logger_init() {
4041
rustwide::logging::init_with(builder.build());
4142
}
4243

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+
4351
#[derive(Debug, Clone, PartialEq, Eq, StructOpt)]
4452
#[structopt(
4553
name = "cratesfyi",
@@ -66,8 +74,13 @@ enum CommandLine {
6674
#[structopt(name = "FOREGROUND", short = "f", long = "foreground")]
6775
foreground: bool,
6876

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,
7184
},
7285

7386
/// Database operations
@@ -103,7 +116,7 @@ impl CommandLine {
103116
}
104117
Self::Daemon {
105118
foreground,
106-
disable_registry_watcher,
119+
registry_watcher,
107120
} => {
108121
if foreground {
109122
log::warn!("--foreground was passed, but there is no need for it anymore");
@@ -113,7 +126,7 @@ impl CommandLine {
113126
ctx.config()?,
114127
ctx.pool()?,
115128
ctx.build_queue()?,
116-
!disable_registry_watcher,
129+
registry_watcher == Toggle::Enabled,
117130
)?;
118131
}
119132
Self::Database { subcommand } => subcommand.handle_args(ctx)?,

0 commit comments

Comments
 (0)