--- /dev/null
+use super::utils::*;
+
+pub fn cli() -> App {
+ subcommand("check")
+ .about("Check a local package and all of its dependencies for errors")
+ .arg_package(
+ "Package(s) to check",
+ "Check all packages in the workspace",
+ "Exclude packages from the check",
+ )
+ .arg_jobs()
+ .arg_target(
+ "Check only this package's library",
+ "Check only the specified binary",
+ "Check all binaries",
+ "Check only the specified example",
+ "Check all examples",
+ "Check only the specified test target",
+ "Check all tests",
+ "Check only the specified bench target",
+ "Check all benches",
+ "Check all targets (lib and bin targets by default)",
+ )
+ .arg_release("Check artifacts in release mode, with optimizations")
+ .arg(
+ opt("profile", "Profile to build the selected target for")
+ .value_name("PROFILE")
+ )
+ .arg_features()
+ .arg_target_triple()
+ .arg_manifest_path()
+ .arg_message_format()
+ .arg_locked()
+ .after_help("\
+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
+current package is built. For more information on SPEC and its format, see the
+`cargo help pkgid` command.
+
+All packages in the workspace are checked if the `--all` flag is supplied. The
+`--all` flag is automatically assumed for a virtual manifest.
+Note that `--exclude` has to be specified in conjunction with the `--all` flag.
+
+Compilation can be configured via the use of profiles which are configured in
+the manifest. The default profile for this command is `dev`, but passing
+the --release flag will use the `release` profile instead.
+
+The `--profile test` flag can be used to check unit tests with the
+`#[cfg(test)]` attribute.
+")
+}
#[cfg(never)]
extern crate cargo;
+use std::slice;
+
use cargo;
-use clap::AppSettings;
-use clap::Arg;
-use clap::SubCommand;
-use clap::ArgMatches;
-use cargo::Config;
-use cargo::CargoResult;
+use clap::{AppSettings, Arg, ArgMatches};
+use cargo::{Config, CargoResult};
use cargo::core::Workspace;
use cargo::util::important_paths::find_root_manifest_for_wd;
-use cargo::ops::Packages;
-use cargo::ops::CompileOptions;
-use cargo::ops;
-use std::slice;
-use cargo::ops::MessageFormat;
+use cargo::ops::{self, MessageFormat, Packages, CompileOptions, CompileMode};
use cargo::CliError;
-use cargo::ops::CompileMode;
pub fn do_main(config: &mut Config) -> Result<(), CliError> {
ops::compile(&ws, &compile_opts)?;
return Ok(());
}
+ ("check", Some(args)) => {
+ config_from_args(config, args)?;
+ let ws = workspace_from_args(config, args)?;
+ let test = match args.value_of("profile") {
+ Some("test") => true,
+ None => false,
+ Some(profile) => {
+ let err = format_err!("unknown profile: `{}`, only `test` is \
+ currently supported", profile);
+ return Err(CliError::new(err, 101))
+ }
+ };
+ let mode = CompileMode::Check { test };
+ let compile_opts = compile_options_from_args(config, args, mode)?;
+ ops::compile(&ws, &compile_opts)?;
+ return Ok(());
+ }
_ => return Ok(())
}
}
.subcommands(vec![
bench::cli(),
build::cli(),
+ check::cli(),
])
;
app
}
+mod bench;
+mod build;
+mod check;
+
mod utils {
use clap::{self, SubCommand, AppSettings};
pub use clap::Arg;
}
fn arg_features(self) -> Self {
- self._arg(
- opt("features", "Space-separated list of features to also build")
- .value_name("FEATURES")
- )
- ._arg(opt("all-features", "Build all available features"))
- ._arg(opt("no-default-features", "Do not build the `default` feature"))
+ self
+ ._arg(
+ opt("features", "Space-separated list of features to also enable")
+ .value_name("FEATURES")
+ )
+ ._arg(opt("all-features", "Enable all available features"))
+ ._arg(opt("no-default-features", "Do not enable the `default` feature"))
+ }
+
+ fn arg_release(self, release: &'static str) -> Self {
+ self._arg(opt("release", release))
}
fn arg_target_triple(self) -> Self {
])
}
}
-
-mod bench;
-mod build;