Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a flag to force network access to be an error #2811

Merged
merged 1 commit into from
Jul 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/bin/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pub struct Options {
flag_example: Vec<String>,
flag_test: Vec<String>,
flag_bench: Vec<String>,
flag_frozen: bool,
flag_locked: bool,
arg_args: Vec<String>,
}

Expand All @@ -46,6 +48,8 @@ Options:
-v, --verbose ... Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date

All of the trailing arguments are passed to the benchmark binaries generated
for filtering benchmarks and generally providing options configuring how they
Expand All @@ -64,9 +68,11 @@ Compilation can be customized with the `bench` profile in the manifest.

pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd()));
try!(config.configure_shell(options.flag_verbose,
options.flag_quiet,
&options.flag_color));
try!(config.configure(options.flag_verbose,
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
options.flag_locked));

let ops = ops::TestOptions {
no_run: options.flag_no_run,
Expand Down
12 changes: 9 additions & 3 deletions src/bin/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ pub struct Options {
flag_example: Vec<String>,
flag_test: Vec<String>,
flag_bench: Vec<String>,
flag_locked: bool,
flag_frozen: bool,
}

pub const USAGE: &'static str = "
Expand All @@ -48,6 +50,8 @@ Options:
-v, --verbose ... Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date

If the --package argument is given, then SPEC is a package id specification
which indicates which package should be built. If it is not given, then the
Expand All @@ -62,9 +66,11 @@ the --release flag will use the `release` profile instead.
pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
debug!("executing; cmd=cargo-build; args={:?}",
env::args().collect::<Vec<_>>());
try!(config.configure_shell(options.flag_verbose,
options.flag_quiet,
&options.flag_color));
try!(config.configure(options.flag_verbose,
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
options.flag_locked));

let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd()));

Expand Down
22 changes: 19 additions & 3 deletions src/bin/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pub struct Flags {
flag_explain: Option<String>,
arg_command: String,
arg_args: Vec<String>,
flag_locked: bool,
flag_frozen: bool,
}

const USAGE: &'static str = "
Expand All @@ -45,6 +47,8 @@ Options:
-v, --verbose ... Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date

Some common cargo commands are (see all commands with --list):
build Compile the current project
Expand All @@ -68,6 +72,16 @@ fn main() {
execute_main_without_stdin(execute, true, USAGE)
}

macro_rules! configure_shell {
($config:expr, $options:expr) => (
try!($config.configure($options.flag_verbose,
$options.flag_quiet,
&$options.flag_color,
$options.flag_frozen,
$options.flag_locked));
)
}

macro_rules! each_subcommand{
($mac:ident) => {
$mac!(bench);
Expand Down Expand Up @@ -113,9 +127,11 @@ each_subcommand!(declare_mod);
on this top-level information.
*/
fn execute(flags: Flags, config: &Config) -> CliResult<Option<()>> {
try!(config.configure_shell(flags.flag_verbose,
flags.flag_quiet,
&flags.flag_color));
try!(config.configure(flags.flag_verbose,
flags.flag_quiet,
&flags.flag_color,
flags.flag_frozen,
flags.flag_locked));

init_git_transports(config);
cargo::util::job::setup();
Expand Down
12 changes: 9 additions & 3 deletions src/bin/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ pub struct Options {
flag_quiet: Option<bool>,
flag_color: Option<String>,
flag_release: bool,
flag_frozen: bool,
flag_locked: bool,
}

pub const USAGE: &'static str = "
Expand All @@ -31,6 +33,8 @@ Options:
-v, --verbose ... Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date

If the --package argument is given, then SPEC is a package id specification
which indicates which package's artifacts should be cleaned out. If it is not
Expand All @@ -40,9 +44,11 @@ and its format, see the `cargo help pkgid` command.

pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
debug!("executing; cmd=cargo-clean; args={:?}", env::args().collect::<Vec<_>>());
try!(config.configure_shell(options.flag_verbose,
options.flag_quiet,
&options.flag_color));
try!(config.configure(options.flag_verbose,
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
options.flag_locked));

let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd()));
let opts = ops::CleanOptions {
Expand Down
12 changes: 9 additions & 3 deletions src/bin/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ pub struct Options {
flag_package: Vec<String>,
flag_lib: bool,
flag_bin: Vec<String>,
flag_frozen: bool,
flag_locked: bool,
}

pub const USAGE: &'static str = "
Expand All @@ -43,6 +45,8 @@ Options:
-v, --verbose ... Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date

By default the documentation for the local package and all dependencies is
built. The output is all placed in `target/doc` in rustdoc's usual format.
Expand All @@ -54,9 +58,11 @@ the `cargo help pkgid` command.
";

pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
try!(config.configure_shell(options.flag_verbose,
options.flag_quiet,
&options.flag_color));
try!(config.configure(options.flag_verbose,
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
options.flag_locked));

let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd()));

Expand Down
12 changes: 9 additions & 3 deletions src/bin/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ pub struct Options {
flag_verbose: u32,
flag_quiet: Option<bool>,
flag_color: Option<String>,
flag_frozen: bool,
flag_locked: bool,
}

pub const USAGE: &'static str = "
Expand All @@ -23,6 +25,8 @@ Options:
-v, --verbose ... Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date

If a lockfile is available, this command will ensure that all of the git
dependencies and/or registries dependencies are downloaded and locally
Expand All @@ -35,9 +39,11 @@ all updated.
";

pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
try!(config.configure_shell(options.flag_verbose,
options.flag_quiet,
&options.flag_color));
try!(config.configure(options.flag_verbose,
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
options.flag_locked));
let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd()));
let ws = try!(Workspace::new(&root, config));
try!(ops::fetch(&ws));
Expand Down
12 changes: 9 additions & 3 deletions src/bin/generate_lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ pub struct Options {
flag_verbose: u32,
flag_quiet: Option<bool>,
flag_color: Option<String>,
flag_frozen: bool,
flag_locked: bool,
}

pub const USAGE: &'static str = "
Expand All @@ -25,13 +27,17 @@ Options:
-v, --verbose ... Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
";

pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
debug!("executing; cmd=cargo-generate-lockfile; args={:?}", env::args().collect::<Vec<_>>());
try!(config.configure_shell(options.flag_verbose,
options.flag_quiet,
&options.flag_color));
try!(config.configure(options.flag_verbose,
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
options.flag_locked));
let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd()));

let ws = try!(Workspace::new(&root, config));
Expand Down
12 changes: 9 additions & 3 deletions src/bin/git_checkout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ pub struct Options {
flag_verbose: u32,
flag_quiet: Option<bool>,
flag_color: Option<String>,
flag_frozen: bool,
flag_locked: bool,
}

pub const USAGE: &'static str = "
Expand All @@ -23,12 +25,16 @@ Options:
-v, --verbose ... Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
";

pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
try!(config.configure_shell(options.flag_verbose,
options.flag_quiet,
&options.flag_color));
try!(config.configure(options.flag_verbose,
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
options.flag_locked));
let Options { flag_url: url, flag_reference: reference, .. } = options;

let url = try!(url.to_url().map_err(|e| {
Expand Down
12 changes: 9 additions & 3 deletions src/bin/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ pub struct Options {
arg_path: Option<String>,
flag_name: Option<String>,
flag_vcs: Option<ops::VersionControl>,
flag_frozen: bool,
flag_locked: bool,
}

pub const USAGE: &'static str = "
Expand All @@ -31,13 +33,17 @@ Options:
-v, --verbose ... Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
";

pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
debug!("executing; cmd=cargo-init; args={:?}", env::args().collect::<Vec<_>>());
try!(config.configure_shell(options.flag_verbose,
options.flag_quiet,
&options.flag_color));
try!(config.configure(options.flag_verbose,
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
options.flag_locked));

let Options { flag_bin, arg_path, flag_name, flag_vcs, .. } = options;

Expand Down
12 changes: 9 additions & 3 deletions src/bin/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ pub struct Options {
flag_root: Option<String>,
flag_list: bool,
flag_force: bool,
flag_frozen: bool,
flag_locked: bool,

arg_crate: Option<String>,
flag_vers: Option<String>,
Expand Down Expand Up @@ -56,6 +58,8 @@ Build and install options:
-v, --verbose ... Use verbose output
-q, --quiet Less output printed to stdout
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date

This command manages Cargo's local set of installed binary crates. Only packages
which have [[bin]] targets can be installed, and all binaries are installed into
Expand Down Expand Up @@ -89,9 +93,11 @@ The `--list` option will list all installed packages (and their versions).
";

pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
try!(config.configure_shell(options.flag_verbose,
options.flag_quiet,
&options.flag_color));
try!(config.configure(options.flag_verbose,
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
options.flag_locked));

let compile_opts = ops::CompileOptions {
config: config,
Expand Down
12 changes: 9 additions & 3 deletions src/bin/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ pub struct Options {
flag_verbose: u32,
flag_quiet: Option<bool>,
flag_color: Option<String>,
flag_frozen: bool,
flag_locked: bool,
}

pub const USAGE: &'static str = "
Expand All @@ -27,13 +29,17 @@ Options:
-v, --verbose ... Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date

";

pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
try!(config.configure_shell(options.flag_verbose,
options.flag_quiet,
&options.flag_color));
try!(config.configure(options.flag_verbose,
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
options.flag_locked));
let token = match options.arg_token.clone() {
Some(token) => token,
None => {
Expand Down
12 changes: 9 additions & 3 deletions src/bin/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ pub struct Options {
flag_no_deps: bool,
flag_quiet: Option<bool>,
flag_verbose: u32,
flag_frozen: bool,
flag_locked: bool,
}

pub const USAGE: &'static str = "
Expand All @@ -34,12 +36,16 @@ Options:
-v, --verbose ... Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
";

pub fn execute(options: Options, config: &Config) -> CliResult<Option<ExportInfo>> {
try!(config.configure_shell(options.flag_verbose,
options.flag_quiet,
&options.flag_color));
try!(config.configure(options.flag_verbose,
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
options.flag_locked));
let manifest = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd()));

let options = OutputMetadataOptions {
Expand Down
Loading