Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Commit 0595417

Browse files
committed
Moved some bits into place to support offline mode.
We currently depend on cargo 0.36 (which is the latest version from crates.io), which doesn't have a stable `--offline` flag yet. However, with the new call to `Config::configure`, we will be able to support it properly in the future. With some minor changes to places where we explicitly update the index, #26 could be solved.
1 parent 602759e commit 0595417

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

src/bin/cargo_semver.rs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn main() {
4545
eprintln!("ERROR: could not initialize logger");
4646
}
4747

48-
let config = match cargo::Config::default() {
48+
let mut config = match cargo::Config::default() {
4949
Ok(cfg) => cfg,
5050
Err(e) => panic!("can't obtain cargo config: {:?}", e),
5151
};
@@ -67,13 +67,28 @@ fn main() {
6767
return;
6868
}
6969

70-
if matches.opt_present("q") {
71-
config
72-
.shell()
73-
.set_verbosity(cargo::core::shell::Verbosity::Quiet);
70+
if let Err(e) = cli::validate_args(&matches) {
71+
cli::exit_with_error(&config, e);
7472
}
7573

76-
if let Err(e) = cli::validate_args(&matches) {
74+
let quiet = if matches.opt_present("q") {
75+
Some(true)
76+
} else {
77+
None
78+
};
79+
80+
let config_res = config.configure(
81+
0, // verbose
82+
quiet,
83+
&None, // color
84+
false, // frozen
85+
false, // locked
86+
// matches.opt_present("offline"),
87+
&None, // target_dir
88+
&[], // unstable_flags
89+
);
90+
91+
if let Err(e) = config_res {
7792
cli::exit_with_error(&config, e);
7893
}
7994

@@ -317,6 +332,7 @@ mod cli {
317332
"use a `name:version` string as current/new crate",
318333
"NAME:VERSION",
319334
);
335+
opts.optflag("", "offline", "Run without accessing the network.");
320336
opts.optopt("", "target", "Build for the target triple", "<TRIPLE>");
321337
opts
322338
}
@@ -471,7 +487,7 @@ impl<'a> WorkInfo<'a> {
471487
);
472488

473489
let mut outdir = env::temp_dir();
474-
// The filename is randomized to avoid clashes when multiple cargo semver are running.
490+
// The filename is randomized to avoid clashes when multiple cargo-semver instances are running.
475491
outdir.push(&format!(
476492
"cargo_semver_{}_{}_{}",
477493
name,

0 commit comments

Comments
 (0)