From 8391cfab004fb27cdafc248a75ef7a3e2558305a Mon Sep 17 00:00:00 2001 From: Maarten de Vries Date: Wed, 6 Sep 2023 16:41:33 +0200 Subject: [PATCH 1/4] Update locked dependency versions. --- Cargo.lock | 375 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 258 insertions(+), 117 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bd47a7a..f5ec0ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "aho-corasick" version = "0.5.3" @@ -11,9 +13,9 @@ dependencies = [ [[package]] name = "ansi_term" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" dependencies = [ "winapi 0.3.9", ] @@ -24,17 +26,11 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", "winapi 0.3.9", ] -[[package]] -name = "autocfg" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" - [[package]] name = "backtrace" version = "0.2.3" @@ -62,9 +58,15 @@ dependencies = [ [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" [[package]] name = "case" @@ -74,11 +76,12 @@ checksum = "fd6c0e7b807d60291f42f33f58480c0bfafe28ed08286446f45e463728cf9c1c" [[package]] name = "cc" -version = "1.0.67" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "jobserver", + "libc", ] [[package]] @@ -95,13 +98,13 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "2.33.3" +version = "2.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "ansi_term", "atty", - "bitflags", + "bitflags 1.3.2", "strsim", "textwrap", "unicode-width", @@ -121,13 +124,13 @@ dependencies = [ [[package]] name = "colored" -version = "2.0.0" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd" +checksum = "2674ec482fbc38012cf31e6c42ba0177b431a0cb6f15fe40efa5aab1bda516f6" dependencies = [ - "atty", + "is-terminal", "lazy_static", - "winapi 0.3.9", + "windows-sys", ] [[package]] @@ -151,15 +154,36 @@ dependencies = [ [[package]] name = "dirs-sys" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" dependencies = [ "libc", "redox_users", "winapi 0.3.9", ] +[[package]] +name = "errno" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "error-chain" version = "0.5.0" @@ -171,11 +195,10 @@ dependencies = [ [[package]] name = "form_urlencoded" -version = "1.0.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" dependencies = [ - "matches", "percent-encoding", ] @@ -187,22 +210,22 @@ checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" [[package]] name = "getrandom" -version = "0.2.2" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if 1.0.0", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", ] [[package]] name = "git2" -version = "0.13.18" +version = "0.13.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b483c6c2145421099df1b4efd50e0f6205479a072199460eff852fa15e5603c7" +checksum = "f29229cc1b24c0e6062f6e742aa3e256492a5323365e5ed3413599f8a5eff7d6" dependencies = [ - "bitflags", + "bitflags 1.3.2", "libc", "libgit2-sys", "log", @@ -213,38 +236,54 @@ dependencies = [ [[package]] name = "heck" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" dependencies = [ "unicode-segmentation", ] [[package]] name = "hermit-abi" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" + [[package]] name = "idna" -version = "0.2.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" dependencies = [ - "matches", "unicode-bidi", "unicode-normalization", ] +[[package]] +name = "is-terminal" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +dependencies = [ + "hermit-abi 0.3.2", + "rustix", + "windows-sys", +] + [[package]] name = "jobserver" -version = "0.1.22" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "972f5ae5d1cb9c6ae417789196c803205313edde988685da5e3aae0827b9e7fd" +checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" dependencies = [ "libc", ] @@ -267,15 +306,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.94" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "libgit2-sys" -version = "0.12.19+1.1.0" +version = "0.12.26+1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f322155d574c8b9ebe991a04f6908bb49e68a79463338d24a43d6274cb6443e6" +checksum = "19e1c899248e606fbfe68dcb31d8b0176ebab833b103824af31bddf4b7457494" dependencies = [ "cc", "libc", @@ -287,9 +326,9 @@ dependencies = [ [[package]] name = "libssh2-sys" -version = "0.2.21" +version = "0.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0186af0d8f171ae6b9c4c90ec51898bad5d08a2d5e470903a50d9ad8959cbee" +checksum = "b094a36eb4b8b8c8a7b4b8ae43b2944502be3e59cd87687595cf6b0a71b3f4ca" dependencies = [ "cc", "libc", @@ -301,9 +340,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.3" +version = "1.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de5435b8549c16d423ed0c03dbaafe57cf6c3344744f1242520d59c9d8ecec66" +checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b" dependencies = [ "cc", "libc", @@ -312,19 +351,16 @@ dependencies = [ ] [[package]] -name = "log" -version = "0.4.14" +name = "linux-raw-sys" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" -dependencies = [ - "cfg-if 1.0.0", -] +checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" [[package]] -name = "matches" -version = "0.1.8" +name = "log" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "memchr" @@ -337,17 +373,16 @@ dependencies = [ [[package]] name = "openssl-probe" -version = "0.1.2" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.62" +version = "0.9.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa52160d45fa2e7608d504b7c3a3355afed615e6d8b627a74458634ba21b69bd" +checksum = "db4d56a4c0478783083cfafcc42493dd4a981d41669da64b4572a2a089b51b1d" dependencies = [ - "autocfg", "cc", "libc", "pkg-config", @@ -356,23 +391,23 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.1.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pkg-config" -version = "0.3.19" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "proc-macro2" -version = "1.0.26" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] @@ -397,9 +432,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.9" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -443,21 +478,22 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.8" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "742739e41cd49414de871ea5e549afb7e2a3ac77b589bcbebe8c82fab37147fc" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] name = "redox_users" -version = "0.4.0" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ "getrandom", "redox_syscall", + "thiserror", ] [[package]] @@ -501,9 +537,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.19" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "410f7acf3cb3a44527c5d9546bad4bf4e6c460915d5f9f2fc524498bfe8f70ce" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustc-serialize" @@ -511,17 +547,33 @@ version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" +[[package]] +name = "rustix" +version = "0.38.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0c3dde1fc030af041adc40e79c0e7fbcf431dd24870053d187d7c66e4b87453" +dependencies = [ + "bitflags 2.4.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + [[package]] name = "serde" -version = "1.0.125" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +dependencies = [ + "serde_derive", +] [[package]] name = "serde_derive" -version = "1.0.125" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", @@ -536,13 +588,13 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "syn" -version = "1.0.72" +version = "2.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82" +checksum = "718fa2415bcb8d8bd775917a1bf12a7931b6dfa890753378538118181e0cb398" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] @@ -570,6 +622,26 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "thiserror" +version = "1.0.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "thread-id" version = "2.0.0" @@ -591,83 +663,80 @@ dependencies = [ [[package]] name = "time" -version = "0.1.43" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" +checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" dependencies = [ "libc", + "wasi 0.10.0+wasi-snapshot-preview1", "winapi 0.3.9", ] [[package]] name = "tinyvec" -version = "1.2.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b5220f05bb7de7f3f53c7c065e1199b3172696fe2db9f9c4d8ad9b4ee74c342" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" dependencies = [ "tinyvec_macros", ] [[package]] name = "tinyvec_macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "toml" -version = "0.5.8" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" dependencies = [ "serde", ] [[package]] name = "unicode-bidi" -version = "0.3.5" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eeb8be209bb1c96b7c177c7420d26e04eccacb0eeae6b980e35fcb74678107e0" -dependencies = [ - "matches", -] +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + +[[package]] +name = "unicode-ident" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "unicode-normalization" -version = "0.1.17" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07fbfce1c8a97d547e8b5334978438d9d6ec8c20e38f56d4a4374d181493eaef" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.7.1" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" [[package]] name = "unicode-width" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" - -[[package]] -name = "unicode-xid" -version = "0.2.2" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" [[package]] name = "url" -version = "2.2.1" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ccd964113622c8e9322cfac19eb1004a07e636c545f325da085d5cdde6f1f8b" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" dependencies = [ "form_urlencoded", "idna", - "matches", "percent-encoding", ] @@ -679,9 +748,9 @@ checksum = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" [[package]] name = "vcpkg" -version = "0.2.12" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbdbff6266a24120518560b5dc983096efb98462e51d0d68169895b237be3e5d" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "vec_map" @@ -691,9 +760,15 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "winapi" @@ -729,6 +804,72 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "yaml-rust" version = "0.3.5" From 89a79df128f5bf3e291bb57a2d4b56e88a34b685 Mon Sep 17 00:00:00 2001 From: Maarten de Vries Date: Wed, 6 Sep 2023 16:39:13 +0200 Subject: [PATCH 2/4] Use `auth_git2` to support cloning private repositories. --- Cargo.lock | 69 +++++++++++++++++++++++++++++++++++++++++++++-------- Cargo.toml | 3 ++- src/main.rs | 5 ++-- 3 files changed, 64 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f5ec0ff..9751803 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -31,6 +31,17 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "auth-git2" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "281984fb591424b18f7eb7219afca511633787955a15f30433a670e4871cc753" +dependencies = [ + "dirs 5.0.1", + "git2", + "terminal-prompt", +] + [[package]] name = "backtrace" version = "0.2.3" @@ -119,7 +130,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "329b012f8172800c7ba02414b726d8664c342e58de6b7adba0b90823544806fc" dependencies = [ "colored", - "dirs", + "dirs 3.0.2", ] [[package]] @@ -149,7 +160,16 @@ version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309" dependencies = [ - "dirs-sys", + "dirs-sys 0.3.7", +] + +[[package]] +name = "dirs" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +dependencies = [ + "dirs-sys 0.4.1", ] [[package]] @@ -163,6 +183,18 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys", +] + [[package]] name = "errno" version = "0.3.3" @@ -221,11 +253,11 @@ dependencies = [ [[package]] name = "git2" -version = "0.13.25" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29229cc1b24c0e6062f6e742aa3e256492a5323365e5ed3413599f8a5eff7d6" +checksum = "12ef350ba88a33b4d524b1d1c79096c9ade5ef8c59395df0e60d1e1889414c0e" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.0", "libc", "libgit2-sys", "log", @@ -312,9 +344,9 @@ checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "libgit2-sys" -version = "0.12.26+1.3.0" +version = "0.16.1+1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e1c899248e606fbfe68dcb31d8b0176ebab833b103824af31bddf4b7457494" +checksum = "f2a2bb3680b094add03bb3732ec520ece34da31a8cd2d633d1389d0f0fb60d0c" dependencies = [ "cc", "libc", @@ -326,9 +358,9 @@ dependencies = [ [[package]] name = "libssh2-sys" -version = "0.2.23" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b094a36eb4b8b8c8a7b4b8ae43b2944502be3e59cd87687595cf6b0a71b3f4ca" +checksum = "2dc8a030b787e2119a731f1951d6a773e2280c660f8ec4b0f5e1505a386e71ee" dependencies = [ "cc", "libc", @@ -389,6 +421,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "percent-encoding" version = "2.3.0" @@ -414,11 +452,12 @@ dependencies = [ name = "project_init" version = "3.1.23" dependencies = [ + "auth-git2", "case", "clap", "cli-setup", "colored", - "dirs", + "dirs 3.0.2", "git2", "heck", "rustache-lists", @@ -607,6 +646,16 @@ dependencies = [ "remove_dir_all", ] +[[package]] +name = "terminal-prompt" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "572818b3472910acbd5dff46a3413715c18e934b071ab2ba464a7b2c2af16376" +dependencies = [ + "libc", + "winapi 0.3.9", +] + [[package]] name = "text_io" version = "0.1.6" diff --git a/Cargo.toml b/Cargo.toml index 6ccaa74..9e535d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,8 @@ rustache-lists = "0.1.0" serde_derive = "1.0" serde = "1.0" text_io = "<= 0.1.6" -git2 = "0.13" +git2 = "0.18" +auth-git2 = "0.5.0" tempdir = "0.3" dirs = "3.0" diff --git a/src/main.rs b/src/main.rs index 409fcc7..d0cfcdc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,7 +17,6 @@ extern crate toml; use case::*; use clap::{App, AppSettings}; use colored::*; -use git2::Repository; use project_init::render::*; use project_init::types::*; use project_init::*; @@ -175,7 +174,9 @@ fn main() { // clone into the temporary directory let file_path = file.path(); - match Repository::clone(&url, file_path) { + + let git_auth = auth_git2::GitAuthenticator::default(); + match git_auth.clone_repo(&url, file_path) { Ok(_) => (), Err(_) => { eprintln!("{}: failed to clone repo at {}", "Error".red(), url); From b58096fa8433ff4af500eb1088528b2730eb274b Mon Sep 17 00:00:00 2001 From: Maarten de Vries Date: Wed, 6 Sep 2023 17:09:49 +0200 Subject: [PATCH 3/4] Update most dependencies (except for clap). --- Cargo.lock | 249 ++++++++++++++++++++++++++++++++++------------------ Cargo.toml | 10 +-- src/lib.rs | 2 +- src/main.rs | 12 ++- 4 files changed, 177 insertions(+), 96 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9751803..3e7b8bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,27 +8,55 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66" dependencies = [ - "memchr", + "memchr 0.1.11", ] [[package]] -name = "ansi_term" -version = "0.12.1" +name = "anstream" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" dependencies = [ - "winapi 0.3.9", + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", ] [[package]] -name = "atty" -version = "0.2.14" +name = "anstyle" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +checksum = "15c4c2c83f81532e5845a733998b6971faca23490340a418e9b72a3ec9de12ea" + +[[package]] +name = "anstyle-parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi 0.3.9", + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" +dependencies = [ + "anstyle", + "windows-sys", ] [[package]] @@ -109,20 +137,31 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "2.34.0" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +checksum = "6a13b88d2c62ff462f88e4a121f17a82c1af05693a2f192b5c38d14de73c19f6" dependencies = [ - "ansi_term", - "atty", - "bitflags 1.3.2", + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", "strsim", - "textwrap", - "unicode-width", - "vec_map", - "yaml-rust", ] +[[package]] +name = "clap_lex" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" + [[package]] name = "cli-setup" version = "0.2.7" @@ -133,6 +172,12 @@ dependencies = [ "dirs 3.0.2", ] +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "colored" version = "2.0.4" @@ -154,6 +199,12 @@ dependencies = [ "winapi-build", ] +[[package]] +name = "deranged" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" + [[package]] name = "dirs" version = "3.0.2" @@ -195,6 +246,12 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "errno" version = "0.3.3" @@ -248,7 +305,7 @@ checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if 1.0.0", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", ] [[package]] @@ -267,22 +324,16 @@ dependencies = [ ] [[package]] -name = "heck" -version = "0.3.3" +name = "hashbrown" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", -] +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" [[package]] -name = "hermit-abi" -version = "0.1.19" +name = "heck" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" @@ -300,13 +351,23 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "indexmap" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +dependencies = [ + "equivalent", + "hashbrown", +] + [[package]] name = "is-terminal" version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.2", + "hermit-abi", "rustix", "windows-sys", ] @@ -403,6 +464,12 @@ dependencies = [ "libc", ] +[[package]] +name = "memchr" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" + [[package]] name = "openssl-probe" version = "0.1.5" @@ -457,7 +524,7 @@ dependencies = [ "clap", "cli-setup", "colored", - "dirs 3.0.2", + "dirs 5.0.1", "git2", "heck", "rustache-lists", @@ -542,7 +609,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" dependencies = [ "aho-corasick", - "memchr", + "memchr 0.1.11", "regex-syntax", "thread_local", "utf8-ranges", @@ -619,11 +686,20 @@ dependencies = [ "syn", ] +[[package]] +name = "serde_spanned" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +dependencies = [ + "serde", +] + [[package]] name = "strsim" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" @@ -658,18 +734,9 @@ dependencies = [ [[package]] name = "text_io" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090d2ee73ae8f01646d500fbb72f99f0b2aea174b7b15d58359bbdf083f73e6d" - -[[package]] -name = "textwrap" -version = "0.11.0" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] +checksum = "d5f0c8eb2ad70c12a6a69508f499b3051c924f4b1cfeae85bfad96e6bc5bba46" [[package]] name = "thiserror" @@ -712,15 +779,21 @@ dependencies = [ [[package]] name = "time" -version = "0.1.45" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" +checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48" dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi 0.3.9", + "deranged", + "serde", + "time-core", ] +[[package]] +name = "time-core" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" + [[package]] name = "tinyvec" version = "1.6.0" @@ -738,11 +811,36 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "toml" -version = "0.5.11" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" dependencies = [ "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.19.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", ] [[package]] @@ -766,18 +864,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-segmentation" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" - -[[package]] -name = "unicode-width" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" - [[package]] name = "url" version = "2.4.1" @@ -796,22 +882,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" [[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - -[[package]] -name = "vec_map" -version = "0.8.2" +name = "utf8parse" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" +name = "vcpkg" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "wasi" @@ -920,7 +1000,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] -name = "yaml-rust" -version = "0.3.5" +name = "winnow" +version = "0.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992" +checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" +dependencies = [ + "memchr 2.6.3", +] diff --git a/Cargo.toml b/Cargo.toml index 9e535d3..2a99b3c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,20 +18,20 @@ cli-setup = "0.2" lto = true [dependencies] -heck = "0.3" +heck = "0.4" case = "1.0" -toml = "0.5" +toml = "0.7" colored = "2.0" clap = {version = "2.29", features = ["yaml"]} -time = "0.1" +time = "0.3" rustache-lists = "0.1.0" serde_derive = "1.0" serde = "1.0" -text_io = "<= 0.1.6" +text_io = "<0.2" git2 = "0.18" auth-git2 = "0.5.0" tempdir = "0.3" -dirs = "3.0" +dirs = "5.0" [[bin]] name = "pi" diff --git a/src/lib.rs b/src/lib.rs index 59a2344..3f902e0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -232,7 +232,7 @@ pub fn init_helper( hash = hash .insert("project", name) .insert("Project", name.to_capitalized()) - .insert("ProjectCamelCase", name.to_camel_case()) + .insert("ProjectCamelCase", name.to_upper_camel_case()) .insert("year", year) .insert("name", author.name) .insert("version", version) diff --git a/src/main.rs b/src/main.rs index d0cfcdc..8170bf9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,7 +28,6 @@ use std::path::Path; use std::path::PathBuf; use std::process::Command; use tempdir::TempDir; -use time::strftime; #[cfg(not(target_os = "windows"))] use std::os::unix::fs::PermissionsExt; @@ -82,9 +81,8 @@ fn main() { }; // get year - let now = time::now(); - let year = now.tm_year + 1900; - let current_date = strftime("%m-%d-%Y", &now).unwrap(); + let now = time::OffsetDateTime::now_utc(); + let current_date = format!("{:02}-{:02}-{:04}", now.month() as u8, now.day(), now.year()); if let Some(x) = matches.subcommand_matches("update") { let force = x.is_present("force"); @@ -198,7 +196,7 @@ fn main() { decoded, author, name, - year, + now.year(), ¤t_date, force, parsed_toml, @@ -304,7 +302,7 @@ fn main() { let hash = HashBuilder::new() .insert("project", name) .insert("Project", name.to_capitalized()) - .insert("year", year) + .insert("year", now.year()) .insert("name", author.name) .insert("version", version) .insert("email", author.email) @@ -523,7 +521,7 @@ fn main() { decoded, author, name, - year, + now.year(), ¤t_date, force, parsed_toml, From 35517a8ed07ea4c72c5cf04dbacbc295ae252719 Mon Sep 17 00:00:00 2001 From: Maarten de Vries Date: Mon, 11 Sep 2023 15:20:38 +0200 Subject: [PATCH 4/4] Update to clap 4. --- Cargo.lock | 37 ++-- Cargo.toml | 2 +- src/main.rs | 559 +++++++++++++++++++++++++++------------------------- 3 files changed, 321 insertions(+), 277 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3e7b8bd..d75e396 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -61,9 +61,9 @@ dependencies = [ [[package]] name = "auth-git2" -version = "0.5.0" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "281984fb591424b18f7eb7219afca511633787955a15f30433a670e4871cc753" +checksum = "4ae57e3232418b3ebbf44a69befe445876a6943d901dd0b13cf159cf73d4a17e" dependencies = [ "dirs 5.0.1", "git2", @@ -142,6 +142,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a13b88d2c62ff462f88e4a121f17a82c1af05693a2f192b5c38d14de73c19f6" dependencies = [ "clap_builder", + "clap_derive", ] [[package]] @@ -156,6 +157,18 @@ dependencies = [ "strsim", ] +[[package]] +name = "clap_derive" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "clap_lex" version = "0.5.1" @@ -445,9 +458,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" +checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128" [[package]] name = "log" @@ -655,9 +668,9 @@ checksum = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" [[package]] name = "rustix" -version = "0.38.11" +version = "0.38.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0c3dde1fc030af041adc40e79c0e7fbcf431dd24870053d187d7c66e4b87453" +checksum = "d7db8590df6dfcd144d22afd1b83b36c21a18d7cbc1dc4bb5295a8712e9eb662" dependencies = [ "bitflags 2.4.0", "errno", @@ -703,9 +716,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "2.0.31" +version = "2.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "718fa2415bcb8d8bd775917a1bf12a7931b6dfa890753378538118181e0cb398" +checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2" dependencies = [ "proc-macro2", "quote", @@ -811,9 +824,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "toml" -version = "0.7.6" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" +checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" dependencies = [ "serde", "serde_spanned", @@ -832,9 +845,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.19.14" +version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ "indexmap", "serde", diff --git a/Cargo.toml b/Cargo.toml index 2a99b3c..cdc3cd5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ heck = "0.4" case = "1.0" toml = "0.7" colored = "2.0" -clap = {version = "2.29", features = ["yaml"]} +clap = { version = "4", features = ["derive"]} time = "0.3" rustache-lists = "0.1.0" serde_derive = "1.0" diff --git a/src/main.rs b/src/main.rs index 8170bf9..678e26a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,5 @@ //! Source file for the binary. #[macro_use] -extern crate clap; -#[macro_use] extern crate text_io; extern crate case; @@ -14,8 +12,7 @@ extern crate tempdir; extern crate time; extern crate toml; -use case::*; -use clap::{App, AppSettings}; +use case::CaseExt; use colored::*; use project_init::render::*; use project_init::types::*; @@ -29,6 +26,95 @@ use std::path::PathBuf; use std::process::Command; use tempdir::TempDir; +#[derive(clap::Parser)] +#[clap(name = "Project Init (pi)")] +#[clap(author = "Vanessa McHale ")] +#[clap(about = "Initialize projects from a template.")] +#[clap(after_help = "See 'man pi' for more information")] +struct App { + #[clap(subcommand)] + command: Subcommand, +} + +#[derive(clap::Subcommand)] +enum Subcommand { + /// Fetch a template from github. + #[clap(visible_alias = "g")] + Git(GitCommand), + + /// List available templates. + /// + /// User templates can be added by placing them in `~/.pi_templates`. + #[clap(visible_alias = "l")] + List, + + /// Update pi (only works on UNIX). + #[clap(visible_alias = "u")] + Update(UpdateCommand), + + /// Use a template from a folder. + #[clap(visible_alias = "i")] + Init(InitCommand), + + /// Use a built-in template. + #[clap(visible_alias = "n")] + New(NewCommand), +} + +#[derive(clap::Parser)] +struct GitCommand { + /// User and repository name where the template is located. + #[clap(value_name = "USER/REPO")] + repo: String, + + /// Project name to be used for project directory. + #[clap(value_name = "NAME")] + name: String, + + /// Initialize project even if directory already exists. + #[clap(long, short)] + force: bool, +} + +#[derive(clap::Parser)] +struct UpdateCommand { + /// Force installation even when binary already exists. + #[clap(long, short)] + force: bool, +} + +#[derive(clap::Parser)] +struct InitCommand { + /// Directory containing your template, either in the current directory or in `$HOME/.pi_templates/`. + #[clap(value_name = "TEMPLATE_DIR")] + directory: PathBuf, + + /// Project name to be used for project directory. + #[clap(value_name = "NAME")] + name: String, + + /// Initialize project even if directory already exists. + #[clap(long, short)] + force: bool, +} + +#[derive(clap::Parser)] +struct NewCommand { + /// Template to be used + /// + /// Currently supported are Rust, Haskell, Idris, Elm, Python, Vimscript, Miso, and Julia. + #[clap(value_name = "TEMPLATE_DIR")] + template: String, + + /// Project name to be used for project directory. + #[clap(value_name = "NAME")] + name: String, + + /// Initialize project even if directory already exists. + #[clap(long, short)] + force: bool, +} + #[cfg(not(target_os = "windows"))] use std::os::unix::fs::PermissionsExt; @@ -50,12 +136,7 @@ fn mk_executable>(_: P) -> () { #[allow(clippy::print_literal)] fn main() { // command-line parser - let yaml = load_yaml!("options-en.yml"); - let matches = App::from_yaml(yaml) - .version(crate_version!()) - .set_term_width(80) - .setting(AppSettings::SubcommandRequired) - .get_matches(); + let args: App = clap::Parser::parse(); // set path to .pi.toml let home = dirs::home_dir().expect("Couldn't determine home directory."); @@ -84,146 +165,120 @@ fn main() { let now = time::OffsetDateTime::now_utc(); let current_date = format!("{:02}-{:02}-{:04}", now.month() as u8, now.day(), now.year()); - if let Some(x) = matches.subcommand_matches("update") { - let force = x.is_present("force"); - - println!("current version: {}", crate_version!()); + match args.command { + Subcommand::Update(args) => { + println!("current version: {}", env!("CARGO_PKG_VERSION")); - let s = if force { - "curl -LSfs https://japaric.github.io/trust/install.sh | sh -s -- --git vmchale/project-init --force" - } else { - "curl -LSfs https://japaric.github.io/trust/install.sh | sh -s -- --git vmchale/project-init" - }; + let s = if args.force { + "curl -LSfs https://japaric.github.io/trust/install.sh | sh -s -- --git vmchale/project-init --force" + } else { + "curl -LSfs https://japaric.github.io/trust/install.sh | sh -s -- --git vmchale/project-init" + }; - let script = Command::new("bash") - .arg("-c") - .arg(s) - .output() - .expect("failed to execute update script."); - - let script_string = String::from_utf8(script.stderr).unwrap(); - - println!("{}", script_string); - } else if matches.subcommand_matches("list").is_some() { - let remote = vec!["vmchale/haskell-ats", "vmchale/madlang-miso"]; - let builtin = vec![ - "rust", "vim", "python", "haskell", "idris", "julia", "elm", "miso", "plain", "kmett", - "madlang", - ]; - println!("{}", "Remote Templates:".cyan()); - for b in remote { - println!(" - {}", b); - } - println!(); - println!("{}", "Builtin Templates:".cyan()); - for b in builtin { - println!(" - {}", b); - } - let mut p = home; - p.push(".pi_templates"); - println!("{}", "\nUser Templates:".cyan()); - let iter = std::fs::read_dir(&p); - match iter { - Ok(x) => { - for dir in x { - if let Ok(x) = dir { - if x.path().is_dir() - && x.file_name().to_str().map(|c| c.chars().next().unwrap()) - != Some('.') - && x.file_name().to_str().map(|c| c.chars().next().unwrap()) - != Some('_') - { - println!(" - {}", x.file_name().to_string_lossy()); + let script = Command::new("bash") + .arg("-c") + .arg(s) + .output() + .expect("failed to execute update script."); + + let script_string = String::from_utf8(script.stderr).unwrap(); + + println!("{}", script_string); + }, + + Subcommand::List => { + let remote = vec!["vmchale/haskell-ats", "vmchale/madlang-miso"]; + let builtin = vec![ + "rust", "vim", "python", "haskell", "idris", "julia", "elm", "miso", "plain", "kmett", + "madlang", + ]; + println!("{}", "Remote Templates:".cyan()); + for b in remote { + println!(" - {}", b); + } + println!(); + println!("{}", "Builtin Templates:".cyan()); + for b in builtin { + println!(" - {}", b); + } + let mut p = home; + p.push(".pi_templates"); + println!("{}", "\nUser Templates:".cyan()); + let iter = std::fs::read_dir(&p); + match iter { + Ok(x) => { + for dir in x { + if let Ok(x) = dir { + if x.path().is_dir() + && x.file_name().to_str().map(|c| c.chars().next().unwrap()) + != Some('.') + && x.file_name().to_str().map(|c| c.chars().next().unwrap()) + != Some('_') + { + println!(" - {}", x.file_name().to_string_lossy()); + } + } else { } - } else { } } + _ => eprintln!("{}: Could not access {}", "Warning".yellow(), p.display()), } - _ => eprintln!("{}: Could not access {}", "Warning".yellow(), p.display()), - } - } else if let Some(matches_init) = matches.subcommand_matches("git") { - // whether to overwrite - let force = matches_init.is_present("force"); - - // get repository name - let repo = matches_init - .value_of("repo") - .expect("Clap failed to supply repository name"); - - // get project name - let name = matches_init - .value_of("name") - .expect("Clap failed to supply project name"); - - // form the URL - let mut url = "https://github.com/".to_string(); - url.push_str(repo); - - // create a temporary directory to hold the template - let dir_name = repo.replace("/", "-"); - let tmp_dir = TempDir::new(&dir_name); - let file = match tmp_dir { - Ok(t) => t, - Err(_) => { - eprintln!("{}: failed to create temporary directory", "Error".red()); - std::process::exit(1) - } - }; - - // clone into the temporary directory - let file_path = file.path(); - - let git_auth = auth_git2::GitAuthenticator::default(); - match git_auth.clone_repo(&url, file_path) { - Ok(_) => (), - Err(_) => { - eprintln!("{}: failed to clone repo at {}", "Error".red(), url); - std::process::exit(1) - } - }; + }, + + Subcommand::Git(args) => { + // form the URL + let url = format!("https://github.com/{}", args.repo); + + // create a temporary directory to hold the template + let dir_name = args.repo.replace("/", "-"); + let tmp_dir = TempDir::new(&dir_name); + let file = match tmp_dir { + Ok(t) => t, + Err(_) => { + eprintln!("{}: failed to create temporary directory", "Error".red()); + std::process::exit(1) + } + }; - let string_dir = file_path.to_string_lossy().to_string(); - let mut toml_string = string_dir.clone(); - toml_string.push_str("/template.toml"); + // clone into the temporary directory + let file_path = file.path(); - // get the parsed TOML file from the repo. - let (parsed_toml, _) = read_toml_dir(&toml_string, PathBuf::from(".")); + let git_auth = auth_git2::GitAuthenticator::default(); + match git_auth.clone_repo(&url, file_path) { + Ok(_) => (), + Err(_) => { + eprintln!("{}: failed to clone repo at {}", "Error".red(), url); + std::process::exit(1) + } + }; - // initialize the project - init_helper( - home, - &string_dir, - decoded, - author, - name, - now.year(), - ¤t_date, - force, - parsed_toml, - false, - ) - } else if let Some(matches_init) = matches.subcommand_matches("new") { - let force: bool = matches_init.occurrences_of("force") == 1; - - // get project name - let name = matches_init - .value_of("name") - .expect("Clap failed to supply project name"); - - // get project template type - let template_str_lower: String = matches_init - .value_of("template") - .expect("Clap failed to supply project directory") - .to_string() - .chars() - .map(|c| c.to_lowercase().to_string()) - .collect::>() - .join(""); - - let template_str = template_str_lower.as_str(); + let string_dir = file_path.to_string_lossy().to_string(); + let mut toml_string = string_dir.clone(); + toml_string.push_str("/template.toml"); + + // get the parsed TOML file from the repo. + let (parsed_toml, _) = read_toml_dir(&toml_string, PathBuf::from(".")); + + // initialize the project + init_helper( + home, + &string_dir, + decoded, + author, + &args.name, + now.year(), + ¤t_date, + args.force, + parsed_toml, + false, + ) + }, + Subcommand::New(args) => { + + let template_str_lower = args.template.to_lowercase(); // read template.toml - let toml_file = match template_str { + let toml_file = match template_str_lower.as_str() { "rust" => includes::RUST_TEMPLATE, "vim" | "vimscript" => includes::VIM_TEMPLATE, "python" => includes::PY_TEMPLATE, @@ -300,8 +355,8 @@ fn main() { // Make a hash for inserting stuff into templates. let hash = HashBuilder::new() - .insert("project", name) - .insert("Project", name.to_capitalized()) + .insert("project", args.name.as_str()) + .insert("Project", args.name.to_capitalized()) .insert("year", now.year()) .insert("name", author.name) .insert("version", version) @@ -311,168 +366,154 @@ fn main() { .insert("date", current_date); // check if the directory exists and exit, if we haven't forced an overwrite. - if Path::new(name).exists() && !force { + if Path::new(&args.name).exists() && !args.force { println!( "Path '{}' already exists. Rerun with -f or --force to overwrite.", - name + args.name ); std::process::exit(0x0f00); }; // create directories - let _ = fs::create_dir(name); + let _ = fs::create_dir(&args.name); if let Some(dirs_pre) = parsed_dirs.directories { - render_dirs(dirs_pre, &hash, name); + render_dirs(dirs_pre, &hash, &args.name); } // Create files. let files = if let Some(files_pre) = parsed_dirs.files { - render_files(files_pre, &hash, name) + render_files(files_pre, &hash, &args.name) } else { VecBuilder::new() }; // create license if it was asked for if let Some(lic) = license_contents { - render_file(lic, name, "LICENSE", &hash); + render_file(lic, &args.name, "LICENSE", &hash); } // render readme if requested if let Some(readme) = parsed_toml.with_readme { if readme { - render_file(includes::README, name, "README.md", &hash); + render_file(includes::README, &args.name, "README.md", &hash); } } let hash_with_files = HashBuilder::new().insert("files", files); // render appropriate stuff by name. - match template_str { + match template_str_lower.as_str() { "plain" => (), "rust" => { let mut bench_path = "benches/".to_string(); - bench_path.push_str(name); + bench_path.push_str(&args.name); bench_path.push_str(".rs"); - write_file_plain(includes::RUST_LIB, name, "src/lib.rs"); - write_file_plain(includes::RUST_MAIN, name, "src/main.rs"); - write_file_plain(includes::RUST_TRAVIS_CI, name, ".travis.yml"); - write_file_plain(includes::RUST_GITIGNORE, name, ".gitignore"); - write_file_plain(includes::RUST_BENCHMARKS, name, &bench_path); - render_file(includes::CARGO_TOML, name, "Cargo.toml", &hash) + write_file_plain(includes::RUST_LIB, &args.name, "src/lib.rs"); + write_file_plain(includes::RUST_MAIN, &args.name, "src/main.rs"); + write_file_plain(includes::RUST_TRAVIS_CI, &args.name, ".travis.yml"); + write_file_plain(includes::RUST_GITIGNORE, &args.name, ".gitignore"); + write_file_plain(includes::RUST_BENCHMARKS, &args.name, &bench_path); + render_file(includes::CARGO_TOML, &args.name, "Cargo.toml", &hash) } "vim" | "vimscript" => { - write_file_plain(includes::VIM_GITIGNORE, name, ".gitignore"); - render_file(includes::VIM_TRAVIS, name, ".travis.yml", &hash_with_files); - render_file(includes::VIMBALL, name, "vimball.txt", &hash_with_files) + write_file_plain(includes::VIM_GITIGNORE, &args.name, ".gitignore"); + render_file(includes::VIM_TRAVIS, &args.name, ".travis.yml", &hash_with_files); + render_file(includes::VIMBALL, &args.name, "vimball.txt", &hash_with_files) } "python" => { - render_file(includes::PY_SETUP, name, "setup.py", &hash); - write_file_plain(includes::PY_CFG, name, "setup.cfg"); - write_file_plain(includes::PY_GITIGNORE, name, ".gitignore"); + render_file(includes::PY_SETUP, &args.name, "setup.py", &hash); + write_file_plain(includes::PY_CFG, &args.name, "setup.cfg"); + write_file_plain(includes::PY_GITIGNORE, &args.name, ".gitignore"); let mut bin_path = "bin/".to_string(); - bin_path.push_str(name); - render_file(includes::PY_BIN, name, &bin_path, &hash); + bin_path.push_str(&args.name); + render_file(includes::PY_BIN, &args.name, &bin_path, &hash); } "miso" => { - write_file_plain(includes::MISO_SETUP_HS, name, "Setup.hs"); - write_file_plain(includes::MISO_MAIN, name, "app/Main.hs"); - write_file_plain(includes::MISO_LIB, name, "src/Lib.hs"); - let mut cabal_path = name.to_string(); - cabal_path.push_str(".cabal"); - render_file(includes::MISO_CABAL, name, &cabal_path, &hash); - write_file_plain(includes::MISO_GITIGNORE, name, ".gitignore"); - render_file(includes::MISO_STACK, name, "stack.yaml", &hash); - write_file_plain(includes::HLINT_TEMPLATE, name, ".hlint.yaml"); - write_file_plain(includes::SHAKE_STACK, name, "stack-shake.yaml"); - write_file_plain(includes::MISO_TRAVIS, name, ".travis.yml"); - render_file(includes::MISO_SHAKE, name, "shake.hs", &hash); - render_file(includes::MISO_HTML, name, "web-src/index.html", &hash); - write_file_plain(includes::HASKELL_TRAVIS_CI, name, ".travis.yml"); - write_file_plain(includes::STYLISH_HASKELL, name, ".stylish-haskell.yaml"); - let mut shake_path = name.to_string(); - shake_path.push_str("/shake.hs"); + write_file_plain(includes::MISO_SETUP_HS, &args.name, "Setup.hs"); + write_file_plain(includes::MISO_MAIN, &args.name, "app/Main.hs"); + write_file_plain(includes::MISO_LIB, &args.name, "src/Lib.hs"); + let cabal_path = format!("{}.cabal", args.name); + render_file(includes::MISO_CABAL, &args.name, &cabal_path, &hash); + write_file_plain(includes::MISO_GITIGNORE, &args.name, ".gitignore"); + render_file(includes::MISO_STACK, &args.name, "stack.yaml", &hash); + write_file_plain(includes::HLINT_TEMPLATE, &args.name, ".hlint.yaml"); + write_file_plain(includes::SHAKE_STACK, &args.name, "stack-shake.yaml"); + write_file_plain(includes::MISO_TRAVIS, &args.name, ".travis.yml"); + render_file(includes::MISO_SHAKE, &args.name, "shake.hs", &hash); + render_file(includes::MISO_HTML, &args.name, "web-src/index.html", &hash); + write_file_plain(includes::HASKELL_TRAVIS_CI, &args.name, ".travis.yml"); + write_file_plain(includes::STYLISH_HASKELL, &args.name, ".stylish-haskell.yaml"); + let shake_path = format!("{}/shake.hs", args.name); mk_executable(shake_path); } "madlang" | "mad" => { - let mut src_path = "src/".to_string(); - src_path.push_str(name); - src_path.push_str(".mad"); - render_file(includes::MADLANG_SRC, name, &src_path, &hash); + let src_path = format!("src/{}.mad", args.name); + render_file(includes::MADLANG_SRC, &args.name, &src_path, &hash); } "idris" => { - let mut pkg_path = name.to_string(); - pkg_path.push_str(".ipkg"); - write_file_plain(includes::IDRIS_GITIGNORE, name, ".gitignore"); - write_file_plain(includes::IDRIS_CTAGS, name, ".ctags"); - let mut main_path = name.to_capitalized(); - main_path.push_str(".idr"); - render_file(includes::IPKG, name, &pkg_path, &hash); - render_file(includes::IPKG_TEST, name, "test.ipkg", &hash); - // render_file(includes::IDRIS_EXE, name, &main_path, &hash); - render_file(includes::IDRIS_TEST, name, "src/Test/Spec.idr", &hash); - let mut lib_path = "src/".to_string(); - lib_path.push_str(&name.to_capitalized()); - lib_path.push('/'); - lib_path.push_str("Lib.idr"); - render_file(includes::IDRIS_LIB, name, &lib_path, &hash); + let pkg_path = format!("{}.ipkg", args.name); + write_file_plain(includes::IDRIS_GITIGNORE, &args.name, ".gitignore"); + write_file_plain(includes::IDRIS_CTAGS, &args.name, ".ctags"); + render_file(includes::IPKG, &args.name, &pkg_path, &hash); + render_file(includes::IPKG_TEST, &args.name, "test.ipkg", &hash); + // let main_path = format!("{}.idr", args.name.to_capitalized()); + // render_file(includes::IDRIS_EXE, args.name, &main_path, &hash); + render_file(includes::IDRIS_TEST, &args.name, "src/Test/Spec.idr", &hash); + let lib_path = format!("src/{}/Lib.idr", args.name.to_capitalized()); + render_file(includes::IDRIS_LIB, &args.name, &lib_path, &hash); } "julia" => { - write_file_plain(includes::JULIA_REQUIRE, name, "REQUIRE"); - let mut project_path = "src/".to_string(); - project_path.push_str(name.to_capitalized().as_str()); - project_path.push_str(".jl"); - write_file_plain(includes::JULIA_GITIGNORE, name, ".gitignore"); - write_file_plain(includes::JULIA_SRC, name, &project_path); - write_file_plain(includes::JULIA_TEST, name, "test/test.jl"); + write_file_plain(includes::JULIA_REQUIRE, &args.name, "REQUIRE"); + let project_path = format!("src/{}.jl", args.name.to_capitalized()); + write_file_plain(includes::JULIA_GITIGNORE, &args.name, ".gitignore"); + write_file_plain(includes::JULIA_SRC, &args.name, &project_path); + write_file_plain(includes::JULIA_TEST, &args.name, "test/test.jl"); } "ats" => { - write_file_plain(includes::ATS_CTAGS, name, ".ctags"); - let mut src_path = "src/".to_string(); - src_path.push_str(name); - src_path.push_str(".dats"); - render_file(includes::ATS_SRC, name, &src_path, &hash); - write_file_plain(includes::ATS_FORMAT, name, ".atsfmt.toml"); - write_file_plain(includes::ATS_TRAVIS, name, ".clang-format"); - render_file(includes::ATS_PKG, name, "atspkg.dhall", &hash); - render_file(includes::ATS_LIB, name, "pkg.dhall", &hash); - render_file(includes::ATS_TRAVIS, name, ".travis.yml", &hash); - render_file(includes::ATS_GITIGNORE, name, ".gitignore", &hash); + write_file_plain(includes::ATS_CTAGS, &args.name, ".ctags"); + let src_path = format!("src/{}.dats", args.name); + render_file(includes::ATS_SRC, &args.name, &src_path, &hash); + write_file_plain(includes::ATS_FORMAT, &args.name, ".atsfmt.toml"); + write_file_plain(includes::ATS_TRAVIS, &args.name, ".clang-format"); + render_file(includes::ATS_PKG, &args.name, "atspkg.dhall", &hash); + render_file(includes::ATS_LIB, &args.name, "pkg.dhall", &hash); + render_file(includes::ATS_TRAVIS, &args.name, ".travis.yml", &hash); + render_file(includes::ATS_GITIGNORE, &args.name, ".gitignore", &hash); } "haskell" | "kmett" => { - write_file_plain(includes::SETUP_HS, name, "Setup.hs"); - write_file_plain(includes::MAIN, name, "app/Main.hs"); - render_file(includes::LIB, name, "src/Lib.hs", &hash); - write_file_plain(includes::BENCH, name, "bench/Bench.hs"); - write_file_plain(includes::TEST, name, "test/Spec.hs"); - write_file_plain(includes::HLINT_TEMPLATE, name, ".hlint.yaml"); - write_file_plain(includes::STYLISH_HASKELL, name, ".stylish-haskell.yaml"); - render_file(includes::DEFAULT_NIX, name, "default.nix", &hash); - render_file(includes::RELEASE_NIX, name, "release.nix", &hash); - let mut cabal_path = name.to_string(); - cabal_path.push_str(".cabal"); - if template_str == "haskell" { - render_file(includes::CABAL, name, &cabal_path, &hash); + write_file_plain(includes::SETUP_HS, &args.name, "Setup.hs"); + write_file_plain(includes::MAIN, &args.name, "app/Main.hs"); + render_file(includes::LIB, &args.name, "src/Lib.hs", &hash); + write_file_plain(includes::BENCH, &args.name, "bench/Bench.hs"); + write_file_plain(includes::TEST, &args.name, "test/Spec.hs"); + write_file_plain(includes::HLINT_TEMPLATE, &args.name, ".hlint.yaml"); + write_file_plain(includes::STYLISH_HASKELL, &args.name, ".stylish-haskell.yaml"); + render_file(includes::DEFAULT_NIX, &args.name, "default.nix", &hash); + render_file(includes::RELEASE_NIX, &args.name, "release.nix", &hash); + let cabal_path = format!("{}.cabal", args.name); + if template_str_lower == "haskell" { + render_file(includes::CABAL, &args.name, &cabal_path, &hash); } else { - render_file(includes::KMETT, name, &cabal_path, &hash); + render_file(includes::KMETT, &args.name, &cabal_path, &hash); } - write_file_plain(includes::HASKELL_GITIGNORE, name, ".gitignore"); - write_file_plain(includes::RELEASE_NIX, name, "release.nix"); - write_file_plain(includes::HSPEC, name, ".hspec"); - write_file_plain(includes::HS_GITATTRIBUTES, name, ".gitattributes"); - render_file(includes::STACK_YAML, name, "stack.yaml", &hash); - render_file(includes::CABAL_PROJECT, name, "cabal.project.local", &hash); - render_file(includes::HASKELL_TRAVIS_CI, name, ".travis.yml", &hash); - render_file(includes::HASKELL_APPVEYOR, name, "appveyor.yml", &hash); - render_file(includes::HS_CHANGELOG, name, "CHANGELOG.md", &hash); + write_file_plain(includes::HASKELL_GITIGNORE, &args.name, ".gitignore"); + write_file_plain(includes::RELEASE_NIX, &args.name, "release.nix"); + write_file_plain(includes::HSPEC, &args.name, ".hspec"); + write_file_plain(includes::HS_GITATTRIBUTES, &args.name, ".gitattributes"); + render_file(includes::STACK_YAML, &args.name, "stack.yaml", &hash); + render_file(includes::CABAL_PROJECT, &args.name, "cabal.project.local", &hash); + render_file(includes::HASKELL_TRAVIS_CI, &args.name, ".travis.yml", &hash); + render_file(includes::HASKELL_APPVEYOR, &args.name, "appveyor.yml", &hash); + render_file(includes::HS_CHANGELOG, &args.name, "CHANGELOG.md", &hash); } _ => std::process::exit(0x0f01), @@ -481,10 +522,10 @@ fn main() { // initialize version control if let Some(vc) = decoded.version_control { match vc.as_str() { - "git" => repo::git_init(name), - "hg" | "mercurial" => repo::hg_init(name), - "pijul" => repo::pijul_init(name), - "darcs" => repo::darcs_init(name), + "git" => repo::git_init(&args.name), + "hg" | "mercurial" => repo::hg_init(&args.name), + "pijul" => repo::pijul_init(&args.name), + "darcs" => repo::darcs_init(&args.name), _ => { eprintln!( "{}: version control {} is not yet supported. Supported version control tools are darcs, pijul, mercurial, and git.", @@ -496,36 +537,26 @@ fn main() { } // Print that we're done - println!("Finished initializing project in {}/", name); - } else if let Some(matches_init) = matches.subcommand_matches("init") { - let force: bool = matches_init.occurrences_of("force") == 1; - - // get project name - let name = matches_init - .value_of("name") - .expect("Failed to supply project name"); - - // get project directory - let project_dir = matches_init - .value_of("directory") - .expect("Failed to supply project directory"); - + println!("Finished initializing project in {}/", args.name); + }, + Subcommand::Init(args) => { + let project_dir = args.directory.to_string_lossy(); // read template.toml for template - let mut template_path = project_dir.to_string(); - template_path.push_str("/template.toml"); + let template_path = format!("{}/template.toml", project_dir); let (parsed_toml, is_global_project) = read_toml_dir(&template_path, home.clone()); init_helper( home, - project_dir, + &project_dir, decoded, author, - name, + &args.name, now.year(), ¤t_date, - force, + args.force, parsed_toml, is_global_project, ) + }, } }