now lets you pull specific packages & added reinit

main
jan Michal 3 years ago
parent b3913e9120
commit ef6a0bc483
No known key found for this signature in database
GPG Key ID: CB521D73AA05EBF2

@ -1,6 +1,6 @@
[package]
name = "Malachite"
version = "0.1.0"
version = "1.1.0"
authors = [ "michal <michal@tar.black>" ]
edition = "2021"
description = "Packaging tool for pacman repositories"

@ -1,7 +1,7 @@
# Maintainer: Matt C <mdc028[at]bucknell[dot]edu>
pkgname=malachite
pkgver=1.0.0
pkgver=1.1.0
pkgrel=1
pkgdesc="Tool for packaging and maintaining pacman repositories"
arch=('any')
@ -21,4 +21,4 @@ package() {
mkdir -p $pkgdir/usr/bin
chmod +x ${srcdir}/malachite/target/release/mlc
cp ${srcdir}/malachite/target/release/mlc $pkgdir/usr/bin/.
}
}

@ -76,10 +76,20 @@ fn main() {
.subcommand(SubCommand::with_name("init").about(
"Clones all git repositories from mlc.toml branching from current directory",
))
.subcommand(SubCommand::with_name("reinit"))
.about("Removes all subdirectories and reinitialises")
.subcommand(
SubCommand::with_name("pull").alias("update").about(
"Pulls all git repositories from mlc.toml branching from current directory",
),
SubCommand::with_name("pull")
.alias("update")
.about(
"Pulls all git repositories from mlc.toml branching from current directory",
)
.arg(
Arg::with_name("package(s)")
.help("The packages to operate on")
.multiple(true)
.index(1),
),
)
.subcommand(
SubCommand::with_name("config").about("Create and/or open local config file"),
@ -148,6 +158,39 @@ fn main() {
}
}
if let true = matches.is_present("reinit") {
let config = workspace::read_cfg();
Command::new("bash")
.args(&["-c", "rm -rf */"])
.spawn()
.unwrap()
.wait()
.unwrap();
if config.mode == "workspace" {
for r in config.repo {
info(format!("Cloning (workspace mode): {}", r));
Command::new("git")
.args(&["clone", &r])
.spawn()
.unwrap()
.wait()
.unwrap();
}
} else if config.mode == "repository" {
for r in config.repo {
info(format!("Cloning (repository mode): {}", r));
Command::new("git")
.args(&["clone", &r])
.spawn()
.unwrap()
.wait()
.unwrap();
}
} else {
crash("Invalid mode in mlc.toml".to_string(), 1);
}
}
if let true = matches.is_present("build") {
let config = workspace::read_cfg();
let mut packages: Vec<String> = matches
@ -215,23 +258,47 @@ fn main() {
}
if let true = matches.is_present("pull") {
let packages: Vec<String> = matches
.subcommand_matches("pull")
.unwrap()
.values_of_lossy("package(s)")
.unwrap_or_default();
let config = workspace::read_cfg();
let cdir = env::current_dir().unwrap();
for r in config.repo {
info(format!("Entering working directory: {}", r));
let dir = format!(
"{}/{}",
env::current_dir().unwrap().display(),
r.split('/').collect::<Vec<&str>>().last().unwrap()
);
env::set_current_dir(dir).unwrap();
Command::new("git")
.args(&["pull", &r])
.spawn()
.unwrap()
.wait()
.unwrap();
env::set_current_dir(&cdir).unwrap();
if packages.is_empty() {
for r in config.repo {
info(format!("Entering working directory: {}", r));
let dir = format!(
"{}/{}",
env::current_dir().unwrap().display(),
r.split('/').collect::<Vec<&str>>().last().unwrap()
);
env::set_current_dir(dir).unwrap();
Command::new("git")
.args(&["pull", &r])
.spawn()
.unwrap()
.wait()
.unwrap();
env::set_current_dir(&cdir).unwrap();
}
} else {
for r in packages {
info(format!("Entering working directory: {}", r));
let dir = format!(
"{}/{}",
env::current_dir().unwrap().display(),
r.split('/').collect::<Vec<&str>>().last().unwrap()
);
env::set_current_dir(dir).unwrap();
Command::new("git")
.args(&["pull", &r])
.spawn()
.unwrap()
.wait()
.unwrap();
env::set_current_dir(&cdir).unwrap();
}
}
}

Loading…
Cancel
Save