diff --git a/.gitignore b/.gitignore index 8c0d7bb..c3ab214 100755 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ /target .idea -Cargo.lock /pkg *tar* \ No newline at end of file diff --git a/example-mlc.toml b/example-mlc.toml index 2ce043f..2daee34 100644 --- a/example-mlc.toml +++ b/example-mlc.toml @@ -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 # diff --git a/flake.nix b/flake.nix index 8211a80..f72710c 100644 --- a/flake.nix +++ b/flake.nix @@ -34,5 +34,7 @@ clippy ]; }; + + formatter = pkgs.alejandra; }); } diff --git a/src/args.rs b/src/args.rs index c569353..fecad99 100644 --- a/src/args.rs +++ b/src/args.rs @@ -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, }, /// Create and/or open local config file diff --git a/src/internal/mod.rs b/src/internal/mod.rs index 8148264..fbf1f31 100755 --- a/src/internal/mod.rs +++ b/src/internal/mod.rs @@ -1,4 +1,4 @@ mod strings; pub mod structs; -pub use strings::*; \ No newline at end of file +pub use strings::*; diff --git a/src/main.rs b/src/main.rs index 1db73ff..2249831 100755 --- a/src/main.rs +++ b/src/main.rs @@ -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" { diff --git a/src/operations/build.rs b/src/operations/build.rs index a41e7c1..18c4bda 100644 --- a/src/operations/build.rs +++ b/src/operations/build.rs @@ -1,10 +1,8 @@ use crate::repository::generate; use crate::{crash, info, repository, workspace}; -pub fn build(mut packages: Vec, all: bool, exclude: Vec, no_regen: bool) { - let all = if packages.is_empty() { - true - }; +pub fn build(mut packages: Vec, exclude: Vec, no_regen: bool) { + let all = packages.is_empty(); let config = workspace::read_cfg(); diff --git a/src/operations/pull.rs b/src/operations/pull.rs index febc865..0cf9387 100644 --- a/src/operations/pull.rs +++ b/src/operations/pull.rs @@ -17,10 +17,8 @@ fn do_the_pulling(packages: Vec) { } } -pub fn pull(packages: Vec, all: bool) { - let all = if packages.is_empty() { - true - }; +pub fn pull(packages: Vec, exclude: Vec) { + 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, all: bool) { let mut dirs = dirs_string.lines().collect::>(); 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);