From 1e12021241bc7448acb45456d2c0c4d393d8ae23 Mon Sep 17 00:00:00 2001
From: michal
Date: Tue, 14 Jun 2022 00:33:23 +0100
Subject: [PATCH 01/12] initial commit for clapv3
---
Cargo.toml | 2 +-
src/args.rs | 67 ++++++++++++++++++++
src/main.rs | 129 ++++++++-------------------------------
src/operations/build.rs | 32 ++--------
src/operations/mod.rs | 26 ++------
src/operations/pull.rs | 51 ++++++----------
src/repository/config.rs | 21 +++++--
src/repository/mod.rs | 14 +----
src/workspace/mod.rs | 6 +-
9 files changed, 141 insertions(+), 207 deletions(-)
create mode 100644 src/args.rs
diff --git a/Cargo.toml b/Cargo.toml
index f44391b..d8ab345 100755
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -18,7 +18,7 @@ codegen-units = 1
[dependencies]
mimalloc = { version = "0.1.27", default-features = false }
-clap = { version = "2.34.0", default-features = false }
+clap = { version = "3.2.1", features = ["derive", "suggestions"] }
toml = { version = "0.5.8", default-features = false }
serde = { version = "1.0.134", default-features = false }
serde_derive = { version = "1.0.134", default-features = false }
diff --git a/src/args.rs b/src/args.rs
new file mode 100644
index 0000000..33ef33b
--- /dev/null
+++ b/src/args.rs
@@ -0,0 +1,67 @@
+use clap::{ArgAction, Parser, Subcommand};
+
+#[derive(Debug, Clone, Parser)]
+#[clap(name="Malachite", version=env!("CARGO_PKG_VERSION"), about=env!("CARGO_PKG_DESCRIPTION"))]
+pub struct Args {
+ #[clap(subcommand)]
+ pub subcommand: Option,
+
+ /// Sets the level of verbosity
+ #[clap(long, short, global(true), action=ArgAction::Count)]
+ pub verbose: u8,
+
+ /// Complete operations without prompting user
+ #[clap(long="noconfirm", global(true), action=ArgAction::SetTrue)]
+ pub no_confirm: bool,
+}
+
+#[derive(Debug, Clone, Subcommand)]
+pub enum Operation {
+ /// Builds the given packages
+ #[clap(name="build", aliases=&["b"])]
+ Build {
+ /// The packages to operate on
+ #[clap(name="package(s)", action=ArgAction::Append, index=1)]
+ packages: Vec,
+
+ /// Builds all packages in mlc.toml (except if -x is specified)
+ #[clap(long="all", action=ArgAction::Append, takes_value=true, conflicts_with="package(s)")]
+ all: bool,
+
+ /// Excludes packages from given operation
+ #[clap(short='x', long="exclude", action=ArgAction::Append, takes_value=true)]
+ exclude: Vec,
+
+ /// Does not regenerate repository after building given package(s)
+ #[clap(short='n', long="no-regen", action=ArgAction::SetTrue)]
+ no_regen: bool,
+ },
+
+ /// Generates repository from built packages
+ #[clap(name="repo-gen", aliases=&["r"])]
+ RepoGen,
+
+ /// Prunes duplicate packages from the repository
+ #[clap(name="prune", aliases=&["p"])]
+ Prune,
+
+ /// Clones all git repositories from mlc.toml branching from current directory
+ #[clap(name="init", aliases=&["i"])]
+ Init,
+
+ /// Pulls in git repositories from mlc.toml branching from current directory
+ #[clap(name="pull", aliases=&["u"])]
+ Pull {
+ /// The packages to operate on
+ #[clap(name="package(s)", help="The packages to operate on", action=ArgAction::Append, index=1)]
+ packages: Vec,
+
+ /// Pulls from all git repositories from mlc.toml branching from current directory
+ #[clap(long="all", action=ArgAction::SetTrue)]
+ all: bool,
+ },
+
+ /// Create and/or open local config file
+ #[clap(name="config", aliases=&["c"])]
+ Config,
+}
diff --git a/src/main.rs b/src/main.rs
index ec19823..37a91b6 100755
--- a/src/main.rs
+++ b/src/main.rs
@@ -2,15 +2,18 @@ use std::env;
use std::path::Path;
use std::process::Command;
+use crate::args::{Args, Operation};
use crate::internal::{crash, info};
use crate::repository::create_config;
-use clap::{App, AppSettings, Arg, ArgSettings, SubCommand};
+use clap::Parser;
use crate::workspace::read_cfg;
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
+mod args;
+
mod internal;
mod operations;
mod repository;
@@ -25,84 +28,7 @@ fn main() {
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);
}
- fn build_app() -> App<'static, 'static> {
- let app = App::new("Malachite")
- .version(env!("CARGO_PKG_VERSION"))
- .about(env!("CARGO_PKG_DESCRIPTION"))
- .arg(
- Arg::with_name("verbose")
- .short("v")
- .long("verbose")
- .multiple(true)
- .set(ArgSettings::Global)
- .help("Sets the level of verbosity"),
- )
- .subcommand(
- SubCommand::with_name("build")
- .about("Builds the given packages")
- .arg(
- Arg::with_name("package(s)")
- .help("The packages to operate on")
- .multiple(true)
- .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"),
- )
- .arg(
- Arg::with_name("no-regen")
- .short("n")
- .long("no-regen")
- .help("Does not regenerate repository after building given package(s)"),
- ),
- )
- .subcommand(
- SubCommand::with_name("repo-gen").about("Generates repository from built packages"),
- )
- .subcommand(
- SubCommand::with_name("prune")
- .about("Prunes duplicate packages from the repository"),
- )
- .subcommand(SubCommand::with_name("init").about(
- "Clones all git repositories from mlc.toml branching from current directory",
- ))
- .subcommand(
- 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"),
- )
- .settings(&[
- AppSettings::GlobalVersion,
- AppSettings::VersionlessSubcommands,
- AppSettings::ArgRequiredElseHelp,
- AppSettings::InferSubcommands,
- ]);
- app
- }
-
- let matches = build_app().get_matches();
+ let args: Args = Args::parse();
if Path::exists("mlc.toml".as_ref()) && Path::exists(".git".as_ref()) {
info(
@@ -130,32 +56,25 @@ fn main() {
env::set_current_dir(dir).unwrap();
}
- if let true = matches.is_present("init") {
- operations::init();
- }
-
- if let true = matches.is_present("build") {
- operations::build(&matches);
- }
-
- if let true = matches.is_present("pull") {
- operations::pull(&matches);
- }
-
- if let true = matches.is_present("repo-gen") {
- let config = read_cfg();
- if config.mode != "repository" {
- panic!("Cannot build packages in workspace mode")
+ match args.subcommand.unwrap_or(Operation::Init) {
+ 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),
+ Operation::RepoGen => {
+ let config = read_cfg();
+ if config.mode != "repository" {
+ panic!("Cannot build packages in workspace mode")
+ }
+ info(format!("Generating repository: {}", config.name.unwrap()));
+ repository::generate();
}
- info(format!("Generating repository: {}", config.name.unwrap()));
- repository::generate();
- }
-
- if let true = matches.is_present("prune") {
- operations::prune();
- }
-
- if let true = matches.is_present("config") {
- operations::config();
+ Operation::Prune => operations::prune(),
+ Operation::Config => operations::config(),
}
}
diff --git a/src/operations/build.rs b/src/operations/build.rs
index af3b32f..8028326 100644
--- a/src/operations/build.rs
+++ b/src/operations/build.rs
@@ -1,20 +1,8 @@
use crate::repository::generate;
use crate::{crash, info, repository, workspace};
-use clap::ArgMatches;
-pub fn build(matches: &ArgMatches) {
+pub fn build(mut packages: Vec, all: bool, exclude: Vec, no_regen: bool) {
let config = workspace::read_cfg();
- let mut packages: Vec = matches
- .subcommand_matches("build")
- .unwrap()
- .values_of_lossy("package(s)")
- .unwrap_or_default();
-
- let exclude: Vec = matches
- .subcommand_matches("build")
- .unwrap()
- .values_of_lossy("exclude")
- .unwrap_or_default();
for pkg in &exclude {
packages.retain(|x| x != pkg);
@@ -31,11 +19,7 @@ pub fn build(matches: &ArgMatches) {
repos.push(a.parse().unwrap());
}
- if matches
- .subcommand_matches("build")
- .unwrap()
- .is_present("exclude")
- {
+ if exclude.is_empty() {
for ex in exclude {
repos.retain(|x| *x != ex);
}
@@ -54,11 +38,7 @@ pub fn build(matches: &ArgMatches) {
}
}
- if matches
- .subcommand_matches("build")
- .unwrap()
- .is_present("all")
- {
+ if all {
for pkg in repos {
let code = repository::build(&pkg);
if code != 0 {
@@ -68,11 +48,7 @@ pub fn build(matches: &ArgMatches) {
generate();
}
- if !matches
- .subcommand_matches("build")
- .unwrap()
- .is_present("no-regen")
- {
+ if !no_regen {
repository::generate();
}
diff --git a/src/operations/mod.rs b/src/operations/mod.rs
index eee2d4b..f3e1f81 100644
--- a/src/operations/mod.rs
+++ b/src/operations/mod.rs
@@ -1,27 +1,11 @@
-use clap::ArgMatches;
-
mod build;
mod config;
mod init;
mod prune;
mod pull;
-pub fn init() {
- init::init();
-}
-
-pub fn build(matches: &ArgMatches) {
- build::build(matches);
-}
-
-pub fn pull(matches: &ArgMatches) {
- pull::pull(matches);
-}
-
-pub fn config() {
- config::config();
-}
-
-pub fn prune() {
- prune::prune();
-}
+pub use build::*;
+pub use config::*;
+pub use init::*;
+pub use prune::*;
+pub use pull::*;
diff --git a/src/operations/pull.rs b/src/operations/pull.rs
index d462b71..5759216 100644
--- a/src/operations/pull.rs
+++ b/src/operations/pull.rs
@@ -1,47 +1,34 @@
use crate::info;
-use clap::ArgMatches;
use std::env;
use std::process::Command;
-pub fn pull(matches: &ArgMatches) {
- let packages: Vec = matches
- .subcommand_matches("pull")
- .unwrap()
- .values_of_lossy("package(s)")
- .unwrap_or_default();
+fn do_the_pulling(packages: Vec) {
+ for dir in packages {
+ let current_dir = env::current_dir().unwrap();
+ info(format!("Entering working directory: {}", dir));
+ env::set_current_dir(dir).unwrap();
+ Command::new("git")
+ .arg("pull")
+ .spawn()
+ .unwrap()
+ .wait()
+ .unwrap();
+ env::set_current_dir(current_dir).unwrap();
+ }
+}
- if packages.is_empty() {
+pub fn pull(packages: Vec, all: bool) {
+ if all {
let stdout = Command::new("ls").arg("-1").output().unwrap().stdout;
let dirs_string = String::from_utf8_lossy(&stdout);
let mut dirs = dirs_string.lines().collect::>();
dirs.retain(|x| *x != "mlc.toml");
+ let dirs_mapped = dirs.iter().map(|x| x.to_string()).collect();
- for dir in dirs {
- let cdir = env::current_dir().unwrap();
- info(format!("Entering working directory: {}", dir));
- env::set_current_dir(dir).unwrap();
- Command::new("git")
- .arg("pull")
- .spawn()
- .unwrap()
- .wait()
- .unwrap();
- env::set_current_dir(cdir).unwrap();
- }
+ do_the_pulling(dirs_mapped);
} else {
- for dir in packages {
- let cdir = env::current_dir().unwrap();
- info(format!("Entering working directory: {}", dir));
- env::set_current_dir(dir).unwrap();
- Command::new("git")
- .arg("pull")
- .spawn()
- .unwrap()
- .wait()
- .unwrap();
- env::set_current_dir(cdir).unwrap();
- }
+ do_the_pulling(packages);
}
}
diff --git a/src/repository/config.rs b/src/repository/config.rs
index dab8a1f..c5740c5 100644
--- a/src/repository/config.rs
+++ b/src/repository/config.rs
@@ -4,10 +4,23 @@ use std::fs::File;
use std::io::Write;
use std::path::Path;
-const DEFAULT_CONFIG: &str = r#"mode = "" # either "repository" or "workspace"
-name = "" # only required when in repository mode, decides what to call the repository and relevant files
-repo = [""] # an array of git repos to clone from, formatted url_index::repo_name, e.g. if you had urls = [ "https://example.com/%repo%" ], 1::package would expand to https://example.com/package
-urls = [""] # an array of urls to clone from, in the format https://example.com/%repo% (the %repo% is NOT optional)"#;
+const DEFAULT_CONFIG: &str = r#"# either "repository" or "workspace"
+mode = ""
+
+# only required when in repository mode, decides what to call the repository and relevant files
+name = ""
+
+# an array of git repos to clone from, formatted url_index::repo_name, e.g. if you had urls = [ "https://example.com/%repo%" ], 1::package would expand to https://example.com/package
+repo = [
+ "",
+ ""
+]
+
+# an array of urls to clone from, in the format https://example.com/%repo% (the %repo% is NOT optional)
+urls = [
+ "",
+ ""
+]"#;
pub fn create_config() {
if env::current_dir()
diff --git a/src/repository/mod.rs b/src/repository/mod.rs
index e5d3231..0d2ce29 100755
--- a/src/repository/mod.rs
+++ b/src/repository/mod.rs
@@ -2,14 +2,6 @@ mod config;
mod package;
mod repo;
-pub fn build(pkg: &str) -> i32 {
- package::build(pkg)
-}
-
-pub fn generate() {
- repo::generate();
-}
-
-pub fn create_config() {
- config::create_config();
-}
+pub use config::*;
+pub use package::*;
+pub use repo::*;
diff --git a/src/workspace/mod.rs b/src/workspace/mod.rs
index 1b19d47..cd2e912 100755
--- a/src/workspace/mod.rs
+++ b/src/workspace/mod.rs
@@ -1,7 +1,3 @@
-use crate::internal::structs::Config;
-
mod read;
-pub fn read_cfg() -> Config {
- read::read_cfg()
-}
+pub use read::*;
From a233523165e00281188dea5a4e5feb668ce21fa9 Mon Sep 17 00:00:00 2001
From: michal
Date: Tue, 14 Jun 2022 01:56:50 +0100
Subject: [PATCH 02/12] fixed #2
---
Cargo.toml | 2 +-
src/args.rs | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index d8ab345..db4f24f 100755
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "Malachite"
-version = "1.2.0"
+version = "1.3.0"
authors = [ "michal " ]
edition = "2021"
description = "Packaging tool for pacman repositories"
diff --git a/src/args.rs b/src/args.rs
index 33ef33b..c569353 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -25,7 +25,7 @@ pub enum Operation {
packages: Vec,
/// Builds all packages in mlc.toml (except if -x is specified)
- #[clap(long="all", action=ArgAction::Append, takes_value=true, conflicts_with="package(s)")]
+ #[clap(long="all", takes_value=false, action=ArgAction::SetTrue, conflicts_with="package(s)")]
all: bool,
/// Excludes packages from given operation
@@ -57,7 +57,7 @@ pub enum Operation {
packages: Vec,
/// Pulls from all git repositories from mlc.toml branching from current directory
- #[clap(long="all", action=ArgAction::SetTrue)]
+ #[clap(long="all", action=ArgAction::SetTrue, conflicts_with="package(s)")]
all: bool,
},
From 6077534fc81c345912e2696cd0b545a58dc3066f Mon Sep 17 00:00:00 2001
From: michal
Date: Tue, 14 Jun 2022 09:52:07 +0100
Subject: [PATCH 03/12] updated versions in cargo.toml + reenabled secure mode
on mimalloc
---
Cargo.toml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index db4f24f..61789d1 100755
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,8 +17,8 @@ lto = "fat"
codegen-units = 1
[dependencies]
-mimalloc = { version = "0.1.27", default-features = false }
+mimalloc = { version = "0.1.29" }
clap = { version = "3.2.1", features = ["derive", "suggestions"] }
-toml = { version = "0.5.8", default-features = false }
-serde = { version = "1.0.134", default-features = false }
-serde_derive = { version = "1.0.134", default-features = false }
+toml = { version = "0.5.9", default-features = false }
+serde = { version = "1.0.137", default-features = false }
+serde_derive = { version = "1.0.137", default-features = false }
From aa7b3f6f783b7e3ff6f3eb0427784930baf08592 Mon Sep 17 00:00:00 2001
From: michal
Date: Tue, 14 Jun 2022 09:52:23 +0100
Subject: [PATCH 04/12] compartmentalised
---
src/internal/mod.rs | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/src/internal/mod.rs b/src/internal/mod.rs
index 8ed88cb..8148264 100755
--- a/src/internal/mod.rs
+++ b/src/internal/mod.rs
@@ -1,10 +1,4 @@
mod strings;
pub mod structs;
-pub fn info(a: String) {
- strings::info(a);
-}
-
-pub fn crash(a: String, b: i32) {
- strings::crash(a, b);
-}
+pub use strings::*;
\ No newline at end of file
From 5f5b567424f9b58da6c9df38d4fe5b32f659f0d3 Mon Sep 17 00:00:00 2001
From: michal
Date: Tue, 14 Jun 2022 09:56:01 +0100
Subject: [PATCH 05/12] formatting changes
---
example-mlc.toml | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/example-mlc.toml b/example-mlc.toml
index 6d5e0e1..2ce043f 100644
--- a/example-mlc.toml
+++ b/example-mlc.toml
@@ -1,14 +1,18 @@
mode = "repository"
name = "test"
-repo = ["1::ame",
- "1::jade",
- "2::notop-git",
- "3::slippy-rb"]
+repo = [
+ "1::ame",
+ "1::jade",
+ "2::notop-git",
+ "3::slippy-rb"
+]
-urls = ["https://git.tar.black/crystal/%repo%",
- "https://aur.archlinux.org/%repo%",
- "https://github.com/jnats/%repo%"]
+urls = [
+ "https://git.tar.black/crystal/%repo%",
+ "https://aur.archlinux.org/%repo%",
+ "https://github.com/jnats/%repo%"
+]
# in this example, mlc will create a repository called "test", with 4 packages
# these packages will be expanded based on the index number they have (index_number::package)
From 0a9db3f8a3878538f8083765f3e8c58ebf612c35 Mon Sep 17 00:00:00 2001
From: michal
Date: Tue, 14 Jun 2022 19:37:27 +0100
Subject: [PATCH 06/12] bumped PKGBUILD ver
---
PKGBUILD | 5 ++---
src/main.rs | 1 -
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/PKGBUILD b/PKGBUILD
index dbb7abb..62d6701 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,13 +1,12 @@
# Maintainer: Matt C
pkgname=malachite
-pkgver=1.2.0
+pkgver=1.3.0
pkgrel=1
pkgdesc="Tool for packaging and maintaining pacman repositories"
license=('GPL3')
arch=('any')
url="https://git.tar.black/crystal/programs/malachite"
-license=('Nolicense')
source=("git+https://git.tar.black/crystal/programs/malachite")
sha256sums=('SKIP')
depends=('git')
@@ -21,5 +20,5 @@ build() {
package() {
mkdir -p $pkgdir/usr/bin
chmod +x ${srcdir}/malachite/target/release/mlc
- cp ${srcdir}/malachite/target/release/mlc $pkgdir/usr/bin/.
+ cp ${srcdir}/malachite/target/release/mlc $pkgdir/usr/bin/.
}
diff --git a/src/main.rs b/src/main.rs
index 37a91b6..1db73ff 100755
--- a/src/main.rs
+++ b/src/main.rs
@@ -13,7 +13,6 @@ use crate::workspace::read_cfg;
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
mod args;
-
mod internal;
mod operations;
mod repository;
From 5b6ecf64f4e2b7c7e6b5f59928109fc33cfd618e Mon Sep 17 00:00:00 2001
From: jasio
Date: Sun, 3 Jul 2022 14:21:53 +0200
Subject: [PATCH 07/12] Update README.md
---
README.md | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 535d687..b77be3a 100644
--- a/README.md
+++ b/README.md
@@ -7,8 +7,12 @@
Malachite
-
-
+
+
+
+
+
+
From f562adc12d5cdab117272f3a89c146782717143c Mon Sep 17 00:00:00 2001
From: jasio
Date: Sun, 3 Jul 2022 14:33:00 +0200
Subject: [PATCH 08/12] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index b77be3a..828bcf3 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@
-
+
From e5e3a3ace740dad1f6e39e00ff31d0395ab2e183 Mon Sep 17 00:00:00 2001
From: jasio
Date: Sat, 9 Jul 2022 19:44:10 +0200
Subject: [PATCH 09/12] Update README.md
---
README.md | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 828bcf3..19f1999 100644
--- a/README.md
+++ b/README.md
@@ -10,9 +10,10 @@
-
-
+
+
+
From 0a5bdc988ecad5a05348ce1dae2215e9a772c95c Mon Sep 17 00:00:00 2001
From: Michal
Date: Tue, 19 Jul 2022 21:22:11 +0100
Subject: [PATCH 10/12] Flake init
---
flake.nix | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
create mode 100644 flake.nix
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..8211a80
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,38 @@
+{
+ inputs = {
+ nixpkgs.url = "github:nixos/nixpkgs";
+ utils.url = "github:numtide/flake-utils";
+ naersk.url = "github:nix-community/naersk";
+ };
+
+ outputs = { self, nixpkgs, utils, naersk }:
+ utils.lib.eachDefaultSystem (system:
+ let
+ pkgs = nixpkgs.legacyPackages."${system}";
+ naersk-lib = naersk.lib."${system}";
+ in rec
+ {
+ packages.malachite = naersk-lib.buildPackage {
+ pname = "mlc";
+ root = ./.;
+ };
+
+ packages.default = packages.malachite;
+
+ apps.malachite = utils.lib.mkApp {
+ drv = packages.malachite;
+ };
+
+ apps.default = apps.malachite;
+
+ devShells.default = pkgs.mkShell {
+ nativeBuildInputs = with pkgs; [
+ rustc
+ cargo
+ rustfmt
+ cargo-audit
+ clippy
+ ];
+ };
+ });
+}
From 17ccd819f9ab8c6ccb7205c7f92cca5704a0be44 Mon Sep 17 00:00:00 2001
From: Michal
Date: Tue, 19 Jul 2022 21:51:04 +0100
Subject: [PATCH 11/12] Implied --all if no packages present\nAdded exclude to
pull
---
Cargo.lock | 292 ++++++++++++++++++++++++++++++++++++++++
flake.lock | 75 +++++++++++
src/operations/build.rs | 4 +
src/operations/pull.rs | 3 +
4 files changed, 374 insertions(+)
create mode 100644 Cargo.lock
create mode 100644 flake.lock
diff --git a/Cargo.lock b/Cargo.lock
new file mode 100644
index 0000000..86dc152
--- /dev/null
+++ b/Cargo.lock
@@ -0,0 +1,292 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "Malachite"
+version = "1.3.0"
+dependencies = [
+ "clap",
+ "mimalloc",
+ "serde",
+ "serde_derive",
+ "toml",
+]
+
+[[package]]
+name = "atty"
+version = "0.2.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
+dependencies = [
+ "hermit-abi",
+ "libc",
+ "winapi",
+]
+
+[[package]]
+name = "autocfg"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
+
+[[package]]
+name = "bitflags"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
+
+[[package]]
+name = "cc"
+version = "1.0.73"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
+
+[[package]]
+name = "clap"
+version = "3.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1df386a2d0f35bdefc0642fd8bcb2cd28243959f028abfd22fbade6f7d30980e"
+dependencies = [
+ "atty",
+ "bitflags",
+ "clap_derive",
+ "clap_lex",
+ "indexmap",
+ "once_cell",
+ "strsim",
+ "termcolor",
+ "textwrap",
+]
+
+[[package]]
+name = "clap_derive"
+version = "3.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7b740354ad9fcf20e27b46d921be4bb3712f5b3c2c7a89ba68a72a8e51d3a47f"
+dependencies = [
+ "heck",
+ "proc-macro-error",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "clap_lex"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5538cd660450ebeb4234cfecf8f2284b844ffc4c50531e66d584ad5b91293613"
+dependencies = [
+ "os_str_bytes",
+]
+
+[[package]]
+name = "hashbrown"
+version = "0.11.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
+
+[[package]]
+name = "heck"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
+
+[[package]]
+name = "hermit-abi"
+version = "0.1.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "indexmap"
+version = "1.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e6012d540c5baa3589337a98ce73408de9b5a25ec9fc2c6fd6be8f0d39e0ca5a"
+dependencies = [
+ "autocfg",
+ "hashbrown",
+]
+
+[[package]]
+name = "libc"
+version = "0.2.126"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
+
+[[package]]
+name = "libmimalloc-sys"
+version = "0.1.25"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "11ca136052550448f55df7898c6dbe651c6b574fe38a0d9ea687a9f8088a2e2c"
+dependencies = [
+ "cc",
+]
+
+[[package]]
+name = "mimalloc"
+version = "0.1.29"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2f64ad83c969af2e732e907564deb0d0ed393cec4af80776f77dd77a1a427698"
+dependencies = [
+ "libmimalloc-sys",
+]
+
+[[package]]
+name = "once_cell"
+version = "1.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225"
+
+[[package]]
+name = "os_str_bytes"
+version = "6.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa"
+
+[[package]]
+name = "proc-macro-error"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
+dependencies = [
+ "proc-macro-error-attr",
+ "proc-macro2",
+ "quote",
+ "syn",
+ "version_check",
+]
+
+[[package]]
+name = "proc-macro-error-attr"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "version_check",
+]
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.39"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "serde"
+version = "1.0.137"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1"
+
+[[package]]
+name = "serde_derive"
+version = "1.0.137"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "strsim"
+version = "0.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
+
+[[package]]
+name = "syn"
+version = "1.0.96"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0748dd251e24453cb8717f0354206b91557e4ec8703673a4b30208f2abaf1ebf"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "termcolor"
+version = "1.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
+dependencies = [
+ "winapi-util",
+]
+
+[[package]]
+name = "textwrap"
+version = "0.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
+
+[[package]]
+name = "toml"
+version = "0.5.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7"
+dependencies = [
+ "serde",
+]
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c"
+
+[[package]]
+name = "version_check"
+version = "0.9.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
+
+[[package]]
+name = "winapi"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
+dependencies = [
+ "winapi-i686-pc-windows-gnu",
+ "winapi-x86_64-pc-windows-gnu",
+]
+
+[[package]]
+name = "winapi-i686-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+
+[[package]]
+name = "winapi-util"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
+dependencies = [
+ "winapi",
+]
+
+[[package]]
+name = "winapi-x86_64-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..e3e611a
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,75 @@
+{
+ "nodes": {
+ "naersk": {
+ "inputs": {
+ "nixpkgs": "nixpkgs"
+ },
+ "locked": {
+ "lastModified": 1655042882,
+ "narHash": "sha256-9BX8Fuez5YJlN7cdPO63InoyBy7dm3VlJkkmTt6fS1A=",
+ "owner": "nix-community",
+ "repo": "naersk",
+ "rev": "cddffb5aa211f50c4b8750adbec0bbbdfb26bb9f",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-community",
+ "repo": "naersk",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1658150454,
+ "narHash": "sha256-dhyOQvRT8oYWN0SwsNyujohBsJqwF5W7fnhEcfgBk7E=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "3110964916469ad6ed9fea72a0a3119a0959a14e",
+ "type": "github"
+ },
+ "original": {
+ "id": "nixpkgs",
+ "type": "indirect"
+ }
+ },
+ "nixpkgs_2": {
+ "locked": {
+ "lastModified": 1658260742,
+ "narHash": "sha256-wpamr67wf4xKa2KFg+H/kN0vRGnQ76obLu+NAw5h9Jw=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "7ecd637ffa005222a4efb7771b3e8ad69460dcb9",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "naersk": "naersk",
+ "nixpkgs": "nixpkgs_2",
+ "utils": "utils"
+ }
+ },
+ "utils": {
+ "locked": {
+ "lastModified": 1656928814,
+ "narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/src/operations/build.rs b/src/operations/build.rs
index 8028326..a41e7c1 100644
--- a/src/operations/build.rs
+++ b/src/operations/build.rs
@@ -2,6 +2,10 @@ 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
+ };
+
let config = workspace::read_cfg();
for pkg in &exclude {
diff --git a/src/operations/pull.rs b/src/operations/pull.rs
index 5759216..febc865 100644
--- a/src/operations/pull.rs
+++ b/src/operations/pull.rs
@@ -18,6 +18,9 @@ fn do_the_pulling(packages: Vec) {
}
pub fn pull(packages: Vec, all: bool) {
+ let all = if packages.is_empty() {
+ true
+ };
if all {
let stdout = Command::new("ls").arg("-1").output().unwrap().stdout;
let dirs_string = String::from_utf8_lossy(&stdout);
From 2fbfc5d8b1a271ae32cfe7f1bde79ccbe24e9bd9 Mon Sep 17 00:00:00 2001
From: Michal
Date: Tue, 19 Jul 2022 21:51:21 +0100
Subject: [PATCH 12/12] Implied --all if no packages present\nAdded exclude to
pull
---
.gitignore | 1 -
example-mlc.toml | 8 ++++----
flake.nix | 2 ++
src/args.rs | 4 ++++
src/internal/mod.rs | 2 +-
src/main.rs | 7 ++++---
src/operations/build.rs | 6 ++----
src/operations/pull.rs | 10 ++++++----
8 files changed, 23 insertions(+), 17 deletions(-)
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);