Implied --all if no packages present\nAdded exclude to pull

main
Michal 2 years ago
parent 17ccd819f9
commit 2fbfc5d8b1
No known key found for this signature in database
GPG Key ID: A6A1A4DCB22279B9

1
.gitignore vendored

@ -1,5 +1,4 @@
/target /target
.idea .idea
Cargo.lock
/pkg /pkg
*tar* *tar*

@ -2,14 +2,14 @@ mode = "repository"
name = "test" name = "test"
repo = [ repo = [
"1::ame", "1::amethyst",
"1::jade", "1::jade",
"2::notop-git", "2::notop-git",
"3::slippy-rb" "3::slippy-rb"
] ]
urls = [ urls = [
"https://git.tar.black/crystal/%repo%", "https://github.com/crystal-linux/%repo%",
"https://aur.archlinux.org/%repo%", "https://aur.archlinux.org/%repo%",
"https://github.com/jnats/%repo%" "https://github.com/jnats/%repo%"
] ]
@ -18,8 +18,8 @@ urls = [
# these packages will be expanded based on the index number they have (index_number::package) # these packages will be expanded based on the index number they have (index_number::package)
# to demonstrate, the ones in this config will expand to the following: # to demonstrate, the ones in this config will expand to the following:
# #
# https://git.tar.black/crystal/ame # https://github.com/crystal-linux/ame
# https://git.tar.black/crystal/jade # https://github.com/crystal-linux/jade
# https://aur.archlinux.org/notop-git # https://aur.archlinux.org/notop-git
# https://github.com/jnats/slippy-rb # https://github.com/jnats/slippy-rb
# #

@ -34,5 +34,7 @@
clippy clippy
]; ];
}; };
formatter = pkgs.alejandra;
}); });
} }

@ -59,6 +59,10 @@ pub enum Operation {
/// Pulls from all git repositories from mlc.toml branching from current directory /// Pulls from all git repositories from mlc.toml branching from current directory
#[clap(long="all", action=ArgAction::SetTrue, conflicts_with="package(s)")] #[clap(long="all", action=ArgAction::SetTrue, conflicts_with="package(s)")]
all: bool, all: bool,
/// Excludes packages from given operation
#[clap(short='x', long="exclude", action=ArgAction::Append, takes_value=true)]
exclude: Vec<String>,
}, },
/// Create and/or open local config file /// Create and/or open local config file

@ -59,12 +59,13 @@ fn main() {
Operation::Init => operations::init(), Operation::Init => operations::init(),
Operation::Build { Operation::Build {
packages, packages,
all,
exclude, exclude,
no_regen, no_regen,
.. ..
} => operations::build(packages, all, exclude, no_regen), } => operations::build(packages, exclude, no_regen),
Operation::Pull { packages, all, .. } => operations::pull(packages, all), Operation::Pull {
packages, exclude, ..
} => operations::pull(packages, exclude),
Operation::RepoGen => { Operation::RepoGen => {
let config = read_cfg(); let config = read_cfg();
if config.mode != "repository" { if config.mode != "repository" {

@ -1,10 +1,8 @@
use crate::repository::generate; use crate::repository::generate;
use crate::{crash, info, repository, workspace}; use crate::{crash, info, repository, workspace};
pub fn build(mut packages: Vec<String>, all: bool, exclude: Vec<String>, no_regen: bool) { pub fn build(mut packages: Vec<String>, exclude: Vec<String>, no_regen: bool) {
let all = if packages.is_empty() { let all = packages.is_empty();
true
};
let config = workspace::read_cfg(); let config = workspace::read_cfg();

@ -17,10 +17,8 @@ fn do_the_pulling(packages: Vec<String>) {
} }
} }
pub fn pull(packages: Vec<String>, all: bool) { pub fn pull(packages: Vec<String>, exclude: Vec<String>) {
let all = if packages.is_empty() { let all = packages.is_empty();
true
};
if all { if all {
let stdout = Command::new("ls").arg("-1").output().unwrap().stdout; let stdout = Command::new("ls").arg("-1").output().unwrap().stdout;
let dirs_string = String::from_utf8_lossy(&stdout); let dirs_string = String::from_utf8_lossy(&stdout);
@ -28,6 +26,10 @@ pub fn pull(packages: Vec<String>, all: bool) {
let mut dirs = dirs_string.lines().collect::<Vec<&str>>(); let mut dirs = dirs_string.lines().collect::<Vec<&str>>();
dirs.retain(|x| *x != "mlc.toml"); dirs.retain(|x| *x != "mlc.toml");
for x in exclude {
dirs.retain(|y| *y != x);
}
let dirs_mapped = dirs.iter().map(|x| x.to_string()).collect(); let dirs_mapped = dirs.iter().map(|x| x.to_string()).collect();
do_the_pulling(dirs_mapped); do_the_pulling(dirs_mapped);

Loading…
Cancel
Save