crash("Running malachite as root is disallowed as it can lead to system breakage. Instead, malachite will prompt you when it needs superuser permissions".to_string(),1);
}
fnbuild_app()-> App<'static,'static>{
letapp=App::new("Malachite")
.version(env!("CARGO_PKG_VERSION"))
@ -25,32 +36,29 @@ fn main() {
.set(ArgSettings::Global)
.help("Sets the level of verbosity"),
)
.arg(
// TODO implement --exclude
Arg::with_name("exclude")
.short("e")
.long("exclude")
.multiple(true)
.set(ArgSettings::Global)
.help("Excludes packages from given operation"),
)
.arg(
// TODO implement --all
Arg::with_name("all")
.long("all")
.set(ArgSettings::Global)
.help("Operates on every possible package"),
)
.subcommand(
SubCommand::with_name("build")
.about("Builds the given packages")
.arg(
Arg::with_name("package(s)")
.help("The packages to operate on")
.required(true)
.multiple(true)
.index(1),
),
)
.arg(
Arg::with_name("all")
.long("all")
.help("Builds all packages in mlc.toml (except if -x is specified)")
.conflicts_with("package(s)")
)
.arg(
Arg::with_name("exclude")
.short("x")
.long("exclude")
.multiple(true)
.takes_value(true)
.help("Excludes packages from given operation")
)
)
.subcommand(
SubCommand::with_name("repo-gen").about("Generates repository from built packages"),
@ -87,6 +95,7 @@ fn main() {
letmatches=build_app().get_matches();
iflettrue=matches.is_present("init"){
letconfig=workspace::read_cfg();
ifconfig.mode=="workspace"{
@ -110,6 +119,7 @@ fn main() {
.unwrap();
info(format!("Entering working directory: {}",r));
letcdir=env::current_dir().unwrap();
letdir=format!(
"{}/{}",
env::current_dir().unwrap().display(),
@ -132,6 +142,9 @@ fn main() {
.unwrap()
.wait()
.unwrap();
info(format!("Exiting work directory: {}",r));
env::set_current_dir(cdir).unwrap();
}
}else{
crash("Invalid mode in mlc.toml".to_string(),1);
@ -140,18 +153,26 @@ fn main() {
iflettrue=matches.is_present("build"){
letconfig=workspace::read_cfg();
letmutpackages: Vec<String>=matches
.subcommand_matches("build")
.unwrap()
.values_of_lossy("package(s)")
.unwrap_or(vec![]);
letexclude: Vec<String>=matches
.subcommand_matches("build")
.unwrap()
.values_of_lossy("exclude")
.unwrap_or(vec![]);
forpkgin&exclude{
packages.retain(|x|&*x!=pkg);
}
ifconfig.mode!="repository"{
crash("Cannot build packages in workspace mode".to_string(),2);