Merge pull request #6 from crystal-linux/clapv3

Clapv3
main
Michal 2 years ago committed by GitHub
commit 1992d5cb67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

1
.gitignore vendored

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

292
Cargo.lock generated

@ -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"

@ -1,6 +1,6 @@
[package]
name = "Malachite"
version = "1.2.0"
version = "1.3.0"
authors = [ "michal <michal@tar.black>" ]
edition = "2021"
description = "Packaging tool for pacman repositories"
@ -17,8 +17,8 @@ lto = "fat"
codegen-units = 1
[dependencies]
mimalloc = { version = "0.1.27", default-features = false }
clap = { version = "2.34.0", default-features = false }
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 }
mimalloc = { version = "0.1.29" }
clap = { version = "3.2.1", features = ["derive", "suggestions"] }
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 }

@ -1,13 +1,12 @@
# Maintainer: Matt C <mdc028[at]bucknell[dot]edu>
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/.
}

@ -1,21 +1,25 @@
mode = "repository"
name = "test"
repo = ["1::ame",
"1::jade",
"2::notop-git",
"3::slippy-rb"]
repo = [
"1::amethyst",
"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://github.com/crystal-linux/%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)
# 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
#

@ -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
}

@ -0,0 +1,40 @@
{
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
];
};
formatter = pkgs.alejandra;
});
}

@ -0,0 +1,71 @@
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<Operation>,
/// 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<String>,
/// Builds all packages in mlc.toml (except if -x is specified)
#[clap(long="all", takes_value=false, 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>,
/// 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<String>,
/// 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
#[clap(name="config", aliases=&["c"])]
Config,
}

@ -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::*;

@ -2,15 +2,17 @@ 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 +27,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 +55,26 @@ 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,
exclude,
no_regen,
..
} => operations::build(packages, exclude, no_regen),
Operation::Pull {
packages, exclude, ..
} => operations::pull(packages, exclude),
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(),
}
}

@ -1,20 +1,10 @@
use crate::repository::generate;
use crate::{crash, info, repository, workspace};
use clap::ArgMatches;
pub fn build(matches: &ArgMatches) {
let config = workspace::read_cfg();
let mut packages: Vec<String> = matches
.subcommand_matches("build")
.unwrap()
.values_of_lossy("package(s)")
.unwrap_or_default();
pub fn build(mut packages: Vec<String>, exclude: Vec<String>, no_regen: bool) {
let all = packages.is_empty();
let exclude: Vec<String> = matches
.subcommand_matches("build")
.unwrap()
.values_of_lossy("exclude")
.unwrap_or_default();
let config = workspace::read_cfg();
for pkg in &exclude {
packages.retain(|x| x != pkg);
@ -31,11 +21,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 +40,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 +50,7 @@ pub fn build(matches: &ArgMatches) {
generate();
}
if !matches
.subcommand_matches("build")
.unwrap()
.is_present("no-regen")
{
if !no_regen {
repository::generate();
}

@ -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::*;

@ -1,47 +1,39 @@
use crate::info;
use clap::ArgMatches;
use std::env;
use std::process::Command;
pub fn pull(matches: &ArgMatches) {
let packages: Vec<String> = matches
.subcommand_matches("pull")
.unwrap()
.values_of_lossy("package(s)")
.unwrap_or_default();
fn do_the_pulling(packages: Vec<String>) {
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<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);
let mut dirs = dirs_string.lines().collect::<Vec<&str>>();
dirs.retain(|x| *x != "mlc.toml");
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();
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);
} 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);
}
}

@ -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()

@ -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::*;

@ -1,7 +1,3 @@
use crate::internal::structs::Config;
mod read;
pub fn read_cfg() -> Config {
read::read_cfg()
}
pub use read::*;

Loading…
Cancel
Save