From ca5e6c9e3d8af7c50a5461c52af00d0b869efc14 Mon Sep 17 00:00:00 2001 From: southerntofu Date: Fri, 1 May 2020 12:48:22 +0200 Subject: [PATCH] Start CLI --- .gitignore | 1 + Cargo.lock | 223 +++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 2 +- src/.main.rs.swp | Bin 12288 -> 0 bytes src/cli.rs | 12 +++ src/main.rs | 8 +- 6 files changed, 244 insertions(+), 2 deletions(-) delete mode 100644 src/.main.rs.swp create mode 100644 src/cli.rs diff --git a/.gitignore b/.gitignore index ea8c4bf..31063c3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +.*.sw* diff --git a/Cargo.lock b/Cargo.lock index 072cf97..c450297 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,46 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +dependencies = [ + "winapi", +] + +[[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 = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "clap" +version = "2.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" +dependencies = [ + "ansi_term", + "atty", + "bitflags", + "strsim", + "textwrap", + "unicode-width", + "vec_map", +] + [[package]] name = "git-build-rs" version = "0.1.0" @@ -7,6 +48,7 @@ dependencies = [ "glob", "lazy_static", "serde_json", + "structopt", ] [[package]] @@ -15,6 +57,24 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" +[[package]] +name = "heck" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hermit-abi" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61565ff7aaace3525556587bd2dc31d4a07071957be715e63ce7b1eccf51a8f4" +dependencies = [ + "libc", +] + [[package]] name = "itoa" version = "0.4.5" @@ -27,6 +87,56 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "libc" +version = "0.2.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005" + +[[package]] +name = "proc-macro-error" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98e9e4b82e0ef281812565ea4751049f1bdcdfccda7d3f459f2e138a40c08678" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f5444ead4e9935abd7f27dc51f7e852a0569ac888096d5ec2499470794e2e53" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "syn-mid", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c1f4b0efa5fc5e8ceb705136bfee52cfdb6a4e3509f770b478cd6ed434232a7" +dependencies = [ + "proc-macro2", +] + [[package]] name = "ryu" version = "1.0.4" @@ -49,3 +159,116 @@ dependencies = [ "ryu", "serde", ] + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "structopt" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "863246aaf5ddd0d6928dfeb1a9ca65f505599e4e1b399935ef7e75107516b4ef" +dependencies = [ + "clap", + "lazy_static", + "structopt-derive", +] + +[[package]] +name = "structopt-derive" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d239ca4b13aee7a2142e6795cbd69e457665ff8037aed33b3effdc430d2f927a" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "syn" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "410a7488c0a728c7ceb4ad59b9567eb4053d02e8cc7f5c0e0eeeb39518369213" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "syn-mid" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7be3539f6c128a931cf19dcee741c1af532c7fd387baa739c03dd2e96479338a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "unicode-segmentation" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" + +[[package]] +name = "unicode-width" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" + +[[package]] +name = "unicode-xid" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" + +[[package]] +name = "vec_map" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" + +[[package]] +name = "version_check" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" + +[[package]] +name = "winapi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +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-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml index 070fa98..66c964b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,5 +10,5 @@ edition = "2018" glob = "0.3" lazy_static = "1.4" # Translations -#serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" +structopt = "0.3" diff --git a/src/.main.rs.swp b/src/.main.rs.swp deleted file mode 100644 index 72cb92b45b85c20c65d1444d5dda77f463216fd2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2%We}f6oy^agj-ka+$pLisF_KjNRgwe8!kn(DiSw|1<@qqNk^U7Bil)ls=$KB zVF>~jEGRp+utSK4;0gGhOiP4>N|%+6r9U3e@j3qec{Pf=&Bu4Qcq>|AXcrj!*nIu$ z!`07h+b}k?62Hf{A}O6NkDvF#7mV*4-H-dZYjlTskv5Ett?9*sBv+BK#}}a)M1TmK zoWRg!jaH3azqZo!$&0}PpTG3z62oM1xKm>>Y5g-CYfCvzQQ%k^=bL=JDpQ(0m zx$5Ws>Z>7jM1Tko0U|&IhyW2F0z`la5CI}U1c<;XB#@+xJ*_eJ9rFMGAAbM;I?vcQ z=qvOEI)FYwZ=p9(0o{OBp^MPZbBw)*-a)UR9cUA}2dzT$Pz^c@{ixPE@M}^d0z`la z5CI}U1c(3;AOb{y2oQn)BQRzhEshK6c%l29LXKp?*SP#=K#hbLB_<3ux9=g~*H^bTVC}(u7O?RVU32QYIF#TOo3l=`bjb z?n!H5@qr%5aLGyQ>Q!m~9OVjE&s`W?$yZvcFU_bp(D%zk3r%*t8pA1-EN1W9T=)ydv2b=;VXYiM~AVoy>$zx zA)lAB=Z*R?SK9GZX1S7S#GgF8z3v^dOmTl*KCFA_1Dyg|d(wjl!nkG6txJXI>7qcf QTq`R?wTbqhFxGCf->ApikN^Mx diff --git a/src/cli.rs b/src/cli.rs new file mode 100644 index 0000000..097914d --- /dev/null +++ b/src/cli.rs @@ -0,0 +1,12 @@ +use structopt::StructOpt; + +#[derive(Debug, StructOpt)] +#[structopt(name = "git-build", about = "Update your repositories and trigger tasks")] +pub struct Cli { + + #[structopt(short = "f", long = "force")] + force: bool, + + //#[structopt(def)] + tasks: Vec, +} diff --git a/src/main.rs b/src/main.rs index 395c6bd..833bc8a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,11 @@ use std::env; use std::collections::HashMap; +use structopt::StructOpt; mod log; mod db; mod dvcs; +mod cli; fn main() { @@ -11,6 +13,10 @@ fn main() { let base_dir = format!("{}/.git-build", home_dir); let db = db::Database::from_folder(&base_dir); + + let cmd = cli::Cli::from_args(); + println!("{:?}", cmd); + let truc = db.tasks(); for task in truc { @@ -24,8 +30,8 @@ fn main() { if !task.dvcs.clone(source) { context.insert("$i18n_source", &source); log::error("clone_failed", Some(&context)); - continue // Skip further processing + continue } } // Otherwise, it's a sourceless task