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
.idea
Cargo.lock
/pkg
*tar*

@ -2,14 +2,14 @@ mode = "repository"
name = "test"
repo = [
"1::ame",
"1::amethyst",
"1::jade",
"2::notop-git",
"3::slippy-rb"
]
urls = [
"https://git.tar.black/crystal/%repo%",
"https://github.com/crystal-linux/%repo%",
"https://aur.archlinux.org/%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)
# to demonstrate, the ones in this config will expand to the following:
#
# https://git.tar.black/crystal/ame
# https://git.tar.black/crystal/jade
# https://github.com/crystal-linux/ame
# https://github.com/crystal-linux/jade
# https://aur.archlinux.org/notop-git
# https://github.com/jnats/slippy-rb
#

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

@ -59,6 +59,10 @@ pub enum Operation {
/// Pulls from all git repositories from mlc.toml branching from current directory
#[clap(long="all", action=ArgAction::SetTrue, conflicts_with="package(s)")]
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

@ -1,4 +1,4 @@
mod strings;
pub mod structs;
pub use strings::*;
pub use strings::*;

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

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

@ -17,10 +17,8 @@ fn do_the_pulling(packages: Vec<String>) {
}
}
pub fn pull(packages: Vec<String>, all: bool) {
let all = if packages.is_empty() {
true
};
pub fn pull(packages: Vec<String>, exclude: Vec<String>) {
let all = packages.is_empty();
if all {
let stdout = Command::new("ls").arg("-1").output().unwrap().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>>();
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();
do_the_pulling(dirs_mapped);

Loading…
Cancel
Save