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>{
fnbuild_app()-> App<'static,'static>{
letapp=App::new("Malachite")
letapp=App::new("Malachite")
.version(env!("CARGO_PKG_VERSION"))
.version(env!("CARGO_PKG_VERSION"))
@ -25,32 +36,29 @@ fn main() {
.set(ArgSettings::Global)
.set(ArgSettings::Global)
.help("Sets the level of verbosity"),
.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(
SubCommand::with_name("build")
SubCommand::with_name("build")
.about("Builds the given packages")
.about("Builds the given packages")
.arg(
.arg(
Arg::with_name("package(s)")
Arg::with_name("package(s)")
.help("The packages to operate on")
.help("The packages to operate on")
.required(true)
.multiple(true)
.multiple(true)
.index(1),
.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(
SubCommand::with_name("repo-gen").about("Generates repository from built packages"),
SubCommand::with_name("repo-gen").about("Generates repository from built packages"),
@ -87,6 +95,7 @@ fn main() {
letmatches=build_app().get_matches();
letmatches=build_app().get_matches();
iflettrue=matches.is_present("init"){
iflettrue=matches.is_present("init"){
letconfig=workspace::read_cfg();
letconfig=workspace::read_cfg();
ifconfig.mode=="workspace"{
ifconfig.mode=="workspace"{
@ -110,6 +119,7 @@ fn main() {
.unwrap();
.unwrap();
info(format!("Entering working directory: {}",r));
info(format!("Entering working directory: {}",r));
letcdir=env::current_dir().unwrap();
letdir=format!(
letdir=format!(
"{}/{}",
"{}/{}",
env::current_dir().unwrap().display(),
env::current_dir().unwrap().display(),
@ -132,6 +142,9 @@ fn main() {
.unwrap()
.unwrap()
.wait()
.wait()
.unwrap();
.unwrap();
info(format!("Exiting work directory: {}",r));
env::set_current_dir(cdir).unwrap();
}
}
}else{
}else{
crash("Invalid mode in mlc.toml".to_string(),1);
crash("Invalid mode in mlc.toml".to_string(),1);
@ -140,18 +153,26 @@ fn main() {
iflettrue=matches.is_present("build"){
iflettrue=matches.is_present("build"){
letconfig=workspace::read_cfg();
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"{
ifconfig.mode!="repository"{
crash("Cannot build packages in workspace mode".to_string(),2);
crash("Cannot build packages in workspace mode".to_string(),2);