diff --git a/Cargo.lock b/Cargo.lock index ec84f72..1feec27 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,78 +1,29 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. [[package]] -name = "abscissa_core" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a07677093120a02583717b6dd1ef81d8de1e8d01bd226c83f0f9bdf3e56bb3a" -dependencies = [ - "abscissa_derive", - "backtrace", - "canonical-path", - "chrono", - "color-backtrace", - "generational-arena", - "gumdrop", - "libc", - "once_cell", - "regex", - "secrecy", - "semver", - "serde", - "signal-hook", - "termcolor", - "toml", - "tracing", - "tracing-log", - "tracing-subscriber", - "wait-timeout", -] - -[[package]] -name = "abscissa_derive" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74f5722bc48763cb9d81d8427ca05b6aa2842f6632cf8e4c0a29eef9baececcc" -dependencies = [ - "darling", - "ident_case", - "proc-macro2", - "quote", - "syn", - "synstructure", -] - -[[package]] -name = "addr2line" -version = "0.15.1" +name = "ansi_term" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03345e98af8f3d786b6d9f656ccfa6ac316d954e92bc4841f0bba20789d5fb5a" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" dependencies = [ - "gimli", + "winapi", ] [[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "aho-corasick" -version = "0.7.18" +name = "anyhow" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" -dependencies = [ - "memchr", -] +checksum = "28b2cd92db5cbd74e8e5028f7e27dd7aa3090e89e4f2a197cc7c8dfb69c7063b" [[package]] -name = "ansi_term" -version = "0.11.0" +name = "async-trait" +version = "0.1.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +checksum = "0b98e84bbb4cbcdd97da190ba0c58a1bb0de2c1fdf67d159e192ed766aeca722" dependencies = [ - "winapi", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -87,49 +38,10 @@ dependencies = [ ] [[package]] -name = "autocfg" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" - -[[package]] -name = "backtrace" -version = "0.3.59" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4717cfcbfaa661a0fd48f8453951837ae7e8f81e481fbb136e3202d72805a744" -dependencies = [ - "addr2line", - "cc", - "cfg-if 1.0.0", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - -[[package]] -name = "canonical-path" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6e9e01327e6c86e92ec72b1c798d4a94810f147209bbe3ffab6a86954937a6f" - -[[package]] -name = "cc" -version = "1.0.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" - -[[package]] -name = "cfg-if" -version = "0.1.10" +name = "bitflags" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "cfg-if" @@ -138,104 +50,69 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] -name = "chrono" -version = "0.4.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" -dependencies = [ - "libc", - "num-integer", - "num-traits", - "serde", - "time", - "winapi", -] - -[[package]] -name = "color-backtrace" -version = "0.3.0" +name = "clap" +version = "2.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65d13f1078cc63c791d0deba0dd43db37c9ec02b311f10bed10b577016f3a957" +checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" dependencies = [ + "ansi_term", "atty", - "backtrace", - "termcolor", -] - -[[package]] -name = "darling" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858" -dependencies = [ - "darling_core", - "darling_macro", + "bitflags", + "strsim", + "textwrap", + "unicode-width", + "vec_map", ] [[package]] -name = "darling_core" -version = "0.10.2" +name = "directories-next" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b" +checksum = "339ee130d97a610ea5a5872d2bbb130fdf68884ff09d3028b81bec8a1ac23bbc" dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn", + "cfg-if", + "dirs-sys-next", ] [[package]] -name = "darling_macro" -version = "0.10.2" +name = "dirs-sys-next" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" dependencies = [ - "darling_core", - "quote", - "syn", + "libc", + "redox_users", + "winapi", ] [[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "generational-arena" -version = "0.2.8" +name = "form_urlencoded" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1d3b771574f62d0548cee0ad9057857e9fc25d7a3335f140c84f6acd0bf601" +checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" dependencies = [ - "cfg-if 0.1.10", + "matches", + "percent-encoding", ] [[package]] -name = "gimli" -version = "0.24.0" +name = "getrandom" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189" - -[[package]] -name = "gumdrop" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee50908bc1beeac1f2902e0b4e0cd0d844e716f5ebdc6f0cfc1163fe5e10bcde" +checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ - "gumdrop_derive", + "cfg-if", + "libc", + "wasi", ] [[package]] -name = "gumdrop_derive" -version = "0.7.0" +name = "heck" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90454ce4de40b7ca6a8968b5ef367bdab48413962588d0d2b1638d60090c35d7" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" dependencies = [ - "proc-macro2", - "quote", - "syn", + "unicode-segmentation", ] [[package]] @@ -248,10 +125,15 @@ dependencies = [ ] [[package]] -name = "ident_case" -version = "1.0.1" +name = "idna" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] [[package]] name = "lazy_static" @@ -271,86 +153,45 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] -name = "matchers" -version = "0.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" -dependencies = [ - "regex-automata", -] - -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - -[[package]] -name = "memchr" -version = "2.4.0" +name = "matches" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" +checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" [[package]] -name = "miniz_oxide" -version = "0.4.4" +name = "percent-encoding" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" -dependencies = [ - "adler", - "autocfg", -] +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] -name = "num-integer" -version = "0.1.44" +name = "proc-macro-error" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ - "autocfg", - "num-traits", + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", ] [[package]] -name = "num-traits" -version = "0.2.14" +name = "proc-macro-error-attr" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "autocfg", -] - -[[package]] -name = "object" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a5b3dd1c072ee7963717671d1ca129f1048fda25edea6b752bfc71ac8854170" - -[[package]] -name = "once_cell" -version = "1.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" - -[[package]] -name = "owning_ref" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce" -dependencies = [ - "stable_deref_trait", + "proc-macro2", + "quote", + "version_check", ] -[[package]] -name = "pin-project-lite" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905" - [[package]] name = "proc-macro2" version = "1.0.27" @@ -370,64 +211,24 @@ dependencies = [ ] [[package]] -name = "regex" -version = "1.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" -dependencies = [ - "byteorder", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.6.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" - -[[package]] -name = "rustc-demangle" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "410f7acf3cb3a44527c5d9546bad4bf4e6c460915d5f9f2fc524498bfe8f70ce" - -[[package]] -name = "secrecy" -version = "0.6.0" +name = "redox_syscall" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9182278ed645df3477a9c27bfee0621c621aa16f6972635f7f795dae3d81070f" +checksum = "742739e41cd49414de871ea5e549afb7e2a3ac77b589bcbebe8c82fab37147fc" dependencies = [ - "serde", - "zeroize", + "bitflags", ] [[package]] -name = "semver" -version = "0.9.0" +name = "redox_users" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" dependencies = [ - "semver-parser", - "serde", + "getrandom", + "redox_syscall", ] -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - [[package]] name = "serde" version = "1.0.126" @@ -449,45 +250,35 @@ dependencies = [ ] [[package]] -name = "signal-hook" -version = "0.1.17" +name = "strsim" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e31d442c16f047a671b5a71e2161d6e68814012b7f5379d269ebd915fac2729" -dependencies = [ - "libc", - "signal-hook-registry", -] +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] -name = "signal-hook-registry" -version = "1.3.0" +name = "structopt" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6" +checksum = "5277acd7ee46e63e5168a80734c9f6ee81b1367a7d8772a2d765df2a3705d28c" dependencies = [ - "libc", + "clap", + "lazy_static", + "structopt-derive", ] [[package]] -name = "smallvec" -version = "0.6.14" +name = "structopt-derive" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" +checksum = "5ba9cdfda491b814720b6b06e0cac513d922fc407582032e8706e9f137976f90" dependencies = [ - "maybe-uninit", + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", ] -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "strsim" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" - [[package]] name = "syn" version = "1.0.72" @@ -500,24 +291,12 @@ dependencies = [ ] [[package]] -name = "synstructure" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "unicode-xid", -] - -[[package]] -name = "termcolor" -version = "1.1.2" +name = "textwrap" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" dependencies = [ - "winapi-util", + "unicode-width", ] [[package]] @@ -541,16 +320,20 @@ dependencies = [ ] [[package]] -name = "time" -version = "0.1.44" +name = "tinyvec" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +checksum = "5b5220f05bb7de7f3f53c7c065e1199b3172696fe2db9f9c4d8ad9b4ee74c342" dependencies = [ - "libc", - "wasi", - "winapi", + "tinyvec_macros", ] +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + [[package]] name = "toml" version = "0.5.8" @@ -561,104 +344,93 @@ dependencies = [ ] [[package]] -name = "tracing" -version = "0.1.26" +name = "unicode-bidi" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d" +checksum = "eeb8be209bb1c96b7c177c7420d26e04eccacb0eeae6b980e35fcb74678107e0" dependencies = [ - "cfg-if 1.0.0", - "pin-project-lite", - "tracing-attributes", - "tracing-core", + "matches", ] [[package]] -name = "tracing-attributes" -version = "0.1.15" +name = "unicode-normalization" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42e6fa53307c8a17e4ccd4dc81cf5ec38db9209f59b222210375b54ee40d1e2" +checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" dependencies = [ - "proc-macro2", - "quote", - "syn", + "tinyvec", ] [[package]] -name = "tracing-core" -version = "0.1.18" +name = "unicode-segmentation" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9ff14f98b1a4b289c6248a023c1c2fa1491062964e9fed67ab29c4e4da4a052" -dependencies = [ - "lazy_static", -] +checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" [[package]] -name = "tracing-log" -version = "0.1.2" +name = "unicode-width" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3" -dependencies = [ - "lazy_static", - "log", - "tracing-core", -] +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" [[package]] -name = "tracing-subscriber" -version = "0.1.6" +name = "unicode-xid" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "192ca16595cdd0661ce319e8eede9c975f227cdaabc4faaefdc256f43d852e45" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "url" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" dependencies = [ - "ansi_term", - "chrono", - "lazy_static", - "matchers", - "owning_ref", - "regex", - "smallvec", - "tracing-core", - "tracing-log", + "form_urlencoded", + "idna", + "matches", + "percent-encoding", ] [[package]] -name = "unicode-xid" -version = "0.2.2" +name = "vec_map" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] -name = "vers" +name = "vers-cli" version = "0.1.0" dependencies = [ - "abscissa_core", - "gumdrop", - "once_cell", - "serde", + "anyhow", + "directories-next", + "structopt", "thiserror", + "vers-core", ] [[package]] name = "vers-core" version = "0.1.0" dependencies = [ + "async-trait", "log", + "serde", "thiserror", + "toml", + "url", ] [[package]] -name = "wait-timeout" -version = "0.2.0" +name = "version_check" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" -dependencies = [ - "libc", -] +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" [[package]] name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" +version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "winapi" @@ -676,23 +448,8 @@ 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" - -[[package]] -name = "zeroize" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" diff --git a/target/debug/.fingerprint/vers-51518290d6b77672/dep-lib-vers b/target/debug/.fingerprint/vers-51518290d6b77672/dep-lib-vers index 2b4d204..28a7c7a 100644 Binary files a/target/debug/.fingerprint/vers-51518290d6b77672/dep-lib-vers and b/target/debug/.fingerprint/vers-51518290d6b77672/dep-lib-vers differ diff --git a/target/debug/deps/libvers-51518290d6b77672.rlib b/target/debug/deps/libvers-51518290d6b77672.rlib index 9bfdfab..c343090 100644 Binary files a/target/debug/deps/libvers-51518290d6b77672.rlib and b/target/debug/deps/libvers-51518290d6b77672.rlib differ diff --git a/target/debug/deps/libvers-51518290d6b77672.rmeta b/target/debug/deps/libvers-51518290d6b77672.rmeta index 1bfcbc5..12030f1 100644 Binary files a/target/debug/deps/libvers-51518290d6b77672.rmeta and b/target/debug/deps/libvers-51518290d6b77672.rmeta differ diff --git a/target/debug/deps/vers-51518290d6b77672.d b/target/debug/deps/vers-51518290d6b77672.d index 2e74147..7eff995 100644 --- a/target/debug/deps/vers-51518290d6b77672.d +++ b/target/debug/deps/vers-51518290d6b77672.d @@ -1,13 +1,13 @@ -/Users/reynn/git/github.com/reynn/vers/target/debug/deps/vers-51518290d6b77672.rmeta: vers-cli/src/lib.rs vers-cli/src/application.rs vers-cli/src/commands.rs vers-cli/src/commands/start.rs vers-cli/src/commands/version.rs vers-cli/src/config.rs vers-cli/src/error.rs vers-cli/src/prelude.rs +/Users/reynn/git/github.com/reynn/vers/target/debug/deps/vers-51518290d6b77672.rmeta: vers-cli/src/lib.rs vers-cli/src/application.rs vers-cli/src/commands.rs vers-cli/src/commands/install.rs vers-cli/src/commands/version.rs vers-cli/src/config.rs vers-cli/src/error.rs vers-cli/src/prelude.rs -/Users/reynn/git/github.com/reynn/vers/target/debug/deps/libvers-51518290d6b77672.rlib: vers-cli/src/lib.rs vers-cli/src/application.rs vers-cli/src/commands.rs vers-cli/src/commands/start.rs vers-cli/src/commands/version.rs vers-cli/src/config.rs vers-cli/src/error.rs vers-cli/src/prelude.rs +/Users/reynn/git/github.com/reynn/vers/target/debug/deps/libvers-51518290d6b77672.rlib: vers-cli/src/lib.rs vers-cli/src/application.rs vers-cli/src/commands.rs vers-cli/src/commands/install.rs vers-cli/src/commands/version.rs vers-cli/src/config.rs vers-cli/src/error.rs vers-cli/src/prelude.rs -/Users/reynn/git/github.com/reynn/vers/target/debug/deps/vers-51518290d6b77672.d: vers-cli/src/lib.rs vers-cli/src/application.rs vers-cli/src/commands.rs vers-cli/src/commands/start.rs vers-cli/src/commands/version.rs vers-cli/src/config.rs vers-cli/src/error.rs vers-cli/src/prelude.rs +/Users/reynn/git/github.com/reynn/vers/target/debug/deps/vers-51518290d6b77672.d: vers-cli/src/lib.rs vers-cli/src/application.rs vers-cli/src/commands.rs vers-cli/src/commands/install.rs vers-cli/src/commands/version.rs vers-cli/src/config.rs vers-cli/src/error.rs vers-cli/src/prelude.rs vers-cli/src/lib.rs: vers-cli/src/application.rs: vers-cli/src/commands.rs: -vers-cli/src/commands/start.rs: +vers-cli/src/commands/install.rs: vers-cli/src/commands/version.rs: vers-cli/src/config.rs: vers-cli/src/error.rs: diff --git a/target/debug/deps/vers_cli b/target/debug/deps/vers_cli index 3148c6f..639be1e 100755 Binary files a/target/debug/deps/vers_cli and b/target/debug/deps/vers_cli differ diff --git a/target/debug/deps/vers_cli.d b/target/debug/deps/vers_cli.d index fe020e8..6250cfa 100644 --- a/target/debug/deps/vers_cli.d +++ b/target/debug/deps/vers_cli.d @@ -1,5 +1,14 @@ -/Users/reynn/git/github.com/reynn/vers/target/debug/deps/vers_cli: vers-cli/src/bin/vers_cli/main.rs +/Users/reynn/git/github.com/reynn/vers/target/debug/deps/vers_cli: vers-cli/src/main.rs vers-cli/src/cli.rs vers-cli/src/cmds/mod.rs vers-cli/src/cmds/change.rs vers-cli/src/cmds/config.rs vers-cli/src/cmds/env.rs vers-cli/src/cmds/install.rs vers-cli/src/cmds/list.rs vers-cli/src/cmds/uninstall.rs vers-cli/src/errors.rs -/Users/reynn/git/github.com/reynn/vers/target/debug/deps/vers_cli.d: vers-cli/src/bin/vers_cli/main.rs +/Users/reynn/git/github.com/reynn/vers/target/debug/deps/vers_cli.d: vers-cli/src/main.rs vers-cli/src/cli.rs vers-cli/src/cmds/mod.rs vers-cli/src/cmds/change.rs vers-cli/src/cmds/config.rs vers-cli/src/cmds/env.rs vers-cli/src/cmds/install.rs vers-cli/src/cmds/list.rs vers-cli/src/cmds/uninstall.rs vers-cli/src/errors.rs -vers-cli/src/bin/vers_cli/main.rs: +vers-cli/src/main.rs: +vers-cli/src/cli.rs: +vers-cli/src/cmds/mod.rs: +vers-cli/src/cmds/change.rs: +vers-cli/src/cmds/config.rs: +vers-cli/src/cmds/env.rs: +vers-cli/src/cmds/install.rs: +vers-cli/src/cmds/list.rs: +vers-cli/src/cmds/uninstall.rs: +vers-cli/src/errors.rs: diff --git a/target/debug/deps/vers_cli.dSYM/Contents/Resources/DWARF/vers_cli b/target/debug/deps/vers_cli.dSYM/Contents/Resources/DWARF/vers_cli index 15743ee..cd89cf1 100644 Binary files a/target/debug/deps/vers_cli.dSYM/Contents/Resources/DWARF/vers_cli and b/target/debug/deps/vers_cli.dSYM/Contents/Resources/DWARF/vers_cli differ diff --git a/target/debug/libvers.d b/target/debug/libvers.d index 50a9083..5643ac9 100644 --- a/target/debug/libvers.d +++ b/target/debug/libvers.d @@ -1 +1 @@ -/Users/reynn/git/github.com/reynn/vers/target/debug/libvers.rlib: /Users/reynn/git/github.com/reynn/vers/vers-cli/src/application.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/commands/start.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/commands/version.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/commands.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/config.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/error.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/lib.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/prelude.rs +/Users/reynn/git/github.com/reynn/vers/target/debug/libvers.rlib: /Users/reynn/git/github.com/reynn/vers/vers-cli/src/application.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/commands/install.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/commands/version.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/commands.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/config.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/error.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/lib.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/prelude.rs diff --git a/target/debug/libvers.rlib b/target/debug/libvers.rlib index 9bfdfab..c343090 100644 Binary files a/target/debug/libvers.rlib and b/target/debug/libvers.rlib differ diff --git a/target/debug/libvers_core.d b/target/debug/libvers_core.d index 76e7505..bb1cee9 100644 --- a/target/debug/libvers_core.d +++ b/target/debug/libvers_core.d @@ -1 +1 @@ -/Users/reynn/git/github.com/reynn/vers/target/debug/libvers_core.rlib: /Users/reynn/git/github.com/reynn/vers/vers-core/src/arch.rs /Users/reynn/git/github.com/reynn/vers/vers-core/src/envs.rs /Users/reynn/git/github.com/reynn/vers/vers-core/src/filters.rs /Users/reynn/git/github.com/reynn/vers/vers-core/src/lib.rs /Users/reynn/git/github.com/reynn/vers/vers-core/src/manager.rs /Users/reynn/git/github.com/reynn/vers/vers-core/src/os.rs /Users/reynn/git/github.com/reynn/vers/vers-core/src/release.rs +/Users/reynn/git/github.com/reynn/vers/target/debug/libvers_core.rlib: /Users/reynn/git/github.com/reynn/vers/vers-core/src/environment/errors.rs /Users/reynn/git/github.com/reynn/vers/vers-core/src/environment/mod.rs /Users/reynn/git/github.com/reynn/vers/vers-core/src/environment/tool.rs /Users/reynn/git/github.com/reynn/vers/vers-core/src/errors.rs /Users/reynn/git/github.com/reynn/vers/vers-core/src/filters.rs /Users/reynn/git/github.com/reynn/vers/vers-core/src/lib.rs /Users/reynn/git/github.com/reynn/vers/vers-core/src/machine/arch.rs /Users/reynn/git/github.com/reynn/vers/vers-core/src/machine/errors.rs /Users/reynn/git/github.com/reynn/vers/vers-core/src/machine/mod.rs /Users/reynn/git/github.com/reynn/vers/vers-core/src/machine/os.rs /Users/reynn/git/github.com/reynn/vers/vers-core/src/machine/os_version.rs /Users/reynn/git/github.com/reynn/vers/vers-core/src/manager.rs /Users/reynn/git/github.com/reynn/vers/vers-core/src/release.rs /Users/reynn/git/github.com/reynn/vers/vers-core/src/version.rs build.rs diff --git a/target/debug/libvers_core.rlib b/target/debug/libvers_core.rlib index 88c50c1..a2e7e7e 100644 Binary files a/target/debug/libvers_core.rlib and b/target/debug/libvers_core.rlib differ diff --git a/target/debug/vers_cli b/target/debug/vers_cli index 3148c6f..1669ab1 100755 Binary files a/target/debug/vers_cli and b/target/debug/vers_cli differ diff --git a/target/debug/vers_cli.d b/target/debug/vers_cli.d index f51cff0..ce5cbd7 100644 --- a/target/debug/vers_cli.d +++ b/target/debug/vers_cli.d @@ -1 +1 @@ -/Users/reynn/git/github.com/reynn/vers/target/debug/vers_cli: /Users/reynn/git/github.com/reynn/vers/vers-cli/src/application.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/bin/vers_cli/main.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/commands/start.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/commands/version.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/commands.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/config.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/error.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/lib.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/prelude.rs +/Users/reynn/git/github.com/reynn/vers/target/debug/vers_cli: /Users/reynn/git/github.com/reynn/vers/vers-cli/src/application.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/bin/vers_cli/main.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/commands/install.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/commands/version.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/commands.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/config.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/error.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/lib.rs /Users/reynn/git/github.com/reynn/vers/vers-cli/src/prelude.rs diff --git a/vers-cli/.gitignore b/vers-cli/.gitignore deleted file mode 100644 index 53eaa21..0000000 --- a/vers-cli/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/target -**/*.rs.bk diff --git a/vers-cli/Cargo.toml b/vers-cli/Cargo.toml index 4bbc052..e2e47aa 100644 --- a/vers-cli/Cargo.toml +++ b/vers-cli/Cargo.toml @@ -1,21 +1,13 @@ +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [package] -name = "vers" authors = ["Nic Patterson "] -version = "0.1.0" edition = "2018" +name = "vers-cli" +version = "0.1.0" [dependencies] -gumdrop = "0.7" -serde = { version = "1", features = ["serde_derive"] } -thiserror = "1" - -[dependencies.abscissa_core] -version = "0.5.2" -# optional: use `gimli` to capture backtraces -# see https://github.com/rust-lang/backtrace-rs/issues/189 -# features = ["gimli-backtrace"] - -[dev-dependencies] -abscissa_core = { version = "0.5.2", features = ["testing"] } -once_cell = "1.2" - +anyhow = "1.0" +directories-next = "2.0" +structopt = "0.3" +thiserror = "1.0" +vers-core = { path = "../vers-core" } diff --git a/vers-cli/README.md b/vers-cli/README.md deleted file mode 100644 index 08c4537..0000000 --- a/vers-cli/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# VersCli - -VersCli is an application. - -## Getting Started - -This application is authored using [Abscissa], a Rust application framework. - -For more information, see: - -[Documentation] - -[Abscissa]: https://github.com/iqlusioninc/abscissa -[Documentation]: https://docs.rs/abscissa_core/ diff --git a/vers-cli/src/application.rs b/vers-cli/src/application.rs deleted file mode 100644 index c772235..0000000 --- a/vers-cli/src/application.rs +++ /dev/null @@ -1,109 +0,0 @@ -//! VersCli Abscissa Application - -use crate::{commands::VersCliCmd, config::VersCliConfig}; -use abscissa_core::{ - application::{self, AppCell}, - config, trace, Application, EntryPoint, FrameworkError, StandardPaths, -}; - -/// Application state -pub static APPLICATION: AppCell = AppCell::new(); - -/// Obtain a read-only (multi-reader) lock on the application state. -/// -/// Panics if the application state has not been initialized. -pub fn app_reader() -> application::lock::Reader { - APPLICATION.read() -} - -/// Obtain an exclusive mutable lock on the application state. -pub fn app_writer() -> application::lock::Writer { - APPLICATION.write() -} - -/// Obtain a read-only (multi-reader) lock on the application configuration. -/// -/// Panics if the application configuration has not been loaded. -pub fn app_config() -> config::Reader { - config::Reader::new(&APPLICATION) -} - -/// VersCli Application -#[derive(Debug)] -pub struct VersCliApp { - /// Application configuration. - config: Option, - - /// Application state. - state: application::State, -} - -/// Initialize a new application instance. -/// -/// By default no configuration is loaded, and the framework state is -/// initialized to a default, empty state (no components, threads, etc). -impl Default for VersCliApp { - fn default() -> Self { - Self { - config: None, - state: application::State::default(), - } - } -} - -impl Application for VersCliApp { - /// Entrypoint command for this application. - type Cmd = EntryPoint; - - /// Application configuration. - type Cfg = VersCliConfig; - - /// Paths to resources within the application. - type Paths = StandardPaths; - - /// Accessor for application configuration. - fn config(&self) -> &VersCliConfig { - self.config.as_ref().expect("config not loaded") - } - - /// Borrow the application state immutably. - fn state(&self) -> &application::State { - &self.state - } - - /// Borrow the application state mutably. - fn state_mut(&mut self) -> &mut application::State { - &mut self.state - } - - /// Register all components used by this application. - /// - /// If you would like to add additional components to your application - /// beyond the default ones provided by the framework, this is the place - /// to do so. - fn register_components(&mut self, command: &Self::Cmd) -> Result<(), FrameworkError> { - let components = self.framework_components(command)?; - self.state.components.register(components) - } - - /// Post-configuration lifecycle callback. - /// - /// Called regardless of whether config is loaded to indicate this is the - /// time in app lifecycle when configuration would be loaded if - /// possible. - fn after_config(&mut self, config: Self::Cfg) -> Result<(), FrameworkError> { - // Configure components - self.state.components.after_config(&config)?; - self.config = Some(config); - Ok(()) - } - - /// Get tracing configuration from command-line options - fn tracing_config(&self, command: &EntryPoint) -> trace::Config { - if command.verbose { - trace::Config::verbose() - } else { - trace::Config::default() - } - } -} diff --git a/vers-cli/src/bin/vers_cli/main.rs b/vers-cli/src/bin/vers_cli/main.rs deleted file mode 100644 index f9a81d3..0000000 --- a/vers-cli/src/bin/vers_cli/main.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! Main entry point for VersCli - -#![deny(warnings, missing_docs, trivial_casts, unused_qualifications)] -#![forbid(unsafe_code)] - -use vers::application::APPLICATION; - -/// Boot VersCli -fn main() { - abscissa_core::boot(&APPLICATION); -} diff --git a/vers-cli/src/cli.rs b/vers-cli/src/cli.rs new file mode 100644 index 0000000..9ead976 --- /dev/null +++ b/vers-cli/src/cli.rs @@ -0,0 +1,17 @@ +use crate::{cmds::*, errors::*}; +use structopt::StructOpt; + +#[derive(Debug, Clone, StructOpt)] +#[structopt(name = "vers")] +pub struct Cli { + #[structopt(short, long, default_value = "default")] + pub env_name: String, + #[structopt(subcommand)] + pub subcommand: Option, +} + +impl Cli { + pub fn new() -> Result { + Ok(Cli::from_args()) + } +} diff --git a/vers-cli/src/cmds/change.rs b/vers-cli/src/cmds/change.rs new file mode 100644 index 0000000..e3339fb --- /dev/null +++ b/vers-cli/src/cmds/change.rs @@ -0,0 +1,8 @@ +use crate::errors::*; +use structopt::StructOpt; + +#[derive(Debug, Clone, StructOpt)] +pub struct Change { + #[structopt(short, long)] + pub name: String, +} diff --git a/vers-cli/src/cmds/config.rs b/vers-cli/src/cmds/config.rs new file mode 100644 index 0000000..e49d44c --- /dev/null +++ b/vers-cli/src/cmds/config.rs @@ -0,0 +1,8 @@ +use crate::errors::*; +use structopt::StructOpt; + +#[derive(Debug, Clone, StructOpt)] +pub struct Config { + #[structopt(short, long)] + pub name: String, +} diff --git a/vers-cli/src/cmds/env.rs b/vers-cli/src/cmds/env.rs new file mode 100644 index 0000000..d8cae70 --- /dev/null +++ b/vers-cli/src/cmds/env.rs @@ -0,0 +1,9 @@ +use crate::errors::*; +use structopt::StructOpt; + +#[derive(Debug, Clone, StructOpt)] +#[structopt(name = "vers")] +pub struct Environment { + #[structopt(short, long, default_value = "default")] + pub name: String, +} diff --git a/vers-cli/src/cmds/install.rs b/vers-cli/src/cmds/install.rs new file mode 100644 index 0000000..f9b0480 --- /dev/null +++ b/vers-cli/src/cmds/install.rs @@ -0,0 +1,8 @@ +use crate::errors::*; +use structopt::StructOpt; + +#[derive(Debug, Clone, StructOpt)] +pub struct Install { + #[structopt(short, long)] + pub name: String, +} diff --git a/vers-cli/src/cmds/list.rs b/vers-cli/src/cmds/list.rs new file mode 100644 index 0000000..aff43e3 --- /dev/null +++ b/vers-cli/src/cmds/list.rs @@ -0,0 +1,10 @@ +use crate::errors::*; +use structopt::StructOpt; + +#[derive(Debug, Clone, StructOpt)] +pub struct List { + #[structopt(short, long, aliases = &["env"])] + pub environment: Option, + #[structopt(short, long)] + pub short: Option, +} diff --git a/vers-cli/src/cmds/mod.rs b/vers-cli/src/cmds/mod.rs new file mode 100644 index 0000000..9560693 --- /dev/null +++ b/vers-cli/src/cmds/mod.rs @@ -0,0 +1,30 @@ +pub mod change; +pub mod config; +pub mod env; +pub mod install; +pub mod list; +pub mod uninstall; + +use structopt::StructOpt; + +#[derive(Debug, Clone, StructOpt)] +pub enum CliSubCommands { + /// Update $PATH variable with different environments or tool versions + #[structopt(aliases = &["ch"])] + Change(change::Change), + /// Generate a new config or change config values in an existing config file. + #[structopt(aliases = &["cfg", "c"])] + Config(config::Config), + /// Manage environments, a default environment is generated automatically + #[structopt(aliases = &["env", "envs"])] + Environment(env::Environment), + /// Install a tool into an environment + #[structopt(aliases = &["add", "i"])] + Install(install::Install), + /// Remove a tool from an environment + #[structopt(aliases = &["remove", "rm"])] + Uninstall(uninstall::Uninstall), + /// List all tools and their current versions for the current environment + #[structopt(aliases = &["ls"])] + List(list::List), +} diff --git a/vers-cli/src/cmds/uninstall.rs b/vers-cli/src/cmds/uninstall.rs new file mode 100644 index 0000000..43e1ba9 --- /dev/null +++ b/vers-cli/src/cmds/uninstall.rs @@ -0,0 +1,8 @@ +use crate::errors::*; +use structopt::StructOpt; + +#[derive(Debug, Clone, StructOpt)] +pub struct Uninstall { + #[structopt(short, long)] + pub name: String, +} diff --git a/vers-cli/src/commands.rs b/vers-cli/src/commands.rs deleted file mode 100644 index 5850c40..0000000 --- a/vers-cli/src/commands.rs +++ /dev/null @@ -1,72 +0,0 @@ -//! VersCli Subcommands -//! -//! This is where you specify the subcommands of your application. -//! -//! The default application comes with two subcommands: -//! -//! - `start`: launches the application -//! - `version`: print application version -//! -//! See the `impl Configurable` below for how to specify the path to the -//! application's configuration file. - -mod start; -mod version; - -use self::{start::StartCmd, version::VersionCmd}; -use crate::config::VersCliConfig; -use abscissa_core::{ - config::Override, Command, Configurable, FrameworkError, Help, Options, Runnable, -}; -use std::path::PathBuf; - -/// VersCli Configuration Filename -pub const CONFIG_FILE: &str = "vers_cli.toml"; - -/// VersCli Subcommands -#[derive(Command, Debug, Options, Runnable)] -pub enum VersCliCmd { - /// The `help` subcommand - #[options(help = "get usage information")] - Help(Help), - - /// The `start` subcommand - #[options(help = "start the application")] - Start(StartCmd), - - /// The `version` subcommand - #[options(help = "display version information")] - Version(VersionCmd), -} - -/// This trait allows you to define how application configuration is loaded. -impl Configurable for VersCliCmd { - /// Location of the configuration file - fn config_path(&self) -> Option { - // Check if the config file exists, and if it does not, ignore it. - // If you'd like for a missing configuration file to be a hard error - // instead, always return `Some(CONFIG_FILE)` here. - let filename = PathBuf::from(CONFIG_FILE); - - if filename.exists() { - Some(filename) - } else { - None - } - } - - /// Apply changes to the config after it's been loaded, e.g. overriding - /// values in a config file using command-line options. - /// - /// This can be safely deleted if you don't want to override config - /// settings from command-line options. - fn process_config( - &self, - config: VersCliConfig, - ) -> Result { - match self { - VersCliCmd::Start(cmd) => cmd.override_config(config), - _ => Ok(config), - } - } -} diff --git a/vers-cli/src/commands/start.rs b/vers-cli/src/commands/start.rs deleted file mode 100644 index 6feb19b..0000000 --- a/vers-cli/src/commands/start.rs +++ /dev/null @@ -1,46 +0,0 @@ -//! `start` subcommand - example of how to write a subcommand - -/// App-local prelude includes `app_reader()`/`app_writer()`/`app_config()` -/// accessors along with logging macros. Customize as you see fit. -use crate::prelude::*; - -use crate::config::VersCliConfig; -use abscissa_core::{config, Command, FrameworkError, Options, Runnable}; - -/// `start` subcommand -/// -/// The `Options` proc macro generates an option parser based on the struct -/// definition, and is defined in the `gumdrop` crate. See their documentation -/// for a more comprehensive example: -/// -/// -#[derive(Command, Debug, Options)] -pub struct StartCmd { - /// To whom are we saying hello? - #[options(free)] - recipient: Vec, -} - -impl Runnable for StartCmd { - /// Start the application. - fn run(&self) { - let config = app_config(); - println!("Hello, {}!", &config.hello.recipient); - } -} - -impl config::Override for StartCmd { - // Process the given command line options, overriding settings from - // a configuration file using explicit flags taken from command-line - // arguments. - fn override_config( - &self, - mut config: VersCliConfig, - ) -> Result { - if !self.recipient.is_empty() { - config.hello.recipient = self.recipient.join(" "); - } - - Ok(config) - } -} diff --git a/vers-cli/src/commands/version.rs b/vers-cli/src/commands/version.rs deleted file mode 100644 index c39045f..0000000 --- a/vers-cli/src/commands/version.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! `version` subcommand - -#![allow(clippy::never_loop)] - -use super::VersCliCmd; -use abscissa_core::{Command, Options, Runnable}; - -/// `version` subcommand -#[derive(Command, Debug, Default, Options)] -pub struct VersionCmd {} - -impl Runnable for VersionCmd { - /// Print version message - fn run(&self) { - println!( - "{} {}", - VersCliCmd::name(), - VersCliCmd::version() - ); - } -} diff --git a/vers-cli/src/config.rs b/vers-cli/src/config.rs deleted file mode 100644 index aa06e8d..0000000 --- a/vers-cli/src/config.rs +++ /dev/null @@ -1,45 +0,0 @@ -//! VersCli Config -//! -//! See instructions in `commands.rs` to specify the path to your -//! application's configuration file and/or command-line options -//! for specifying it. - -use serde::{Deserialize, Serialize}; - -/// VersCli Configuration -#[derive(Clone, Debug, Deserialize, Serialize)] -#[serde(deny_unknown_fields)] -pub struct VersCliConfig { - /// An example configuration section - pub hello: ExampleSection, -} - -/// Default configuration settings. -/// -/// Note: if your needs are as simple as below, you can -/// use `#[derive(Default)]` on VersCliConfig instead. -impl Default for VersCliConfig { - fn default() -> Self { - Self { - hello: ExampleSection::default(), - } - } -} - -/// Example configuration section. -/// -/// Delete this and replace it with your actual configuration structs. -#[derive(Clone, Debug, Deserialize, Serialize)] -#[serde(deny_unknown_fields)] -pub struct ExampleSection { - /// Example configuration value - pub recipient: String, -} - -impl Default for ExampleSection { - fn default() -> Self { - Self { - recipient: "world".to_owned(), - } - } -} diff --git a/vers-cli/src/error.rs b/vers-cli/src/error.rs deleted file mode 100644 index cdc847f..0000000 --- a/vers-cli/src/error.rs +++ /dev/null @@ -1,70 +0,0 @@ -//! Error types - -use abscissa_core::error::{BoxError, Context}; -use std::{ - fmt::{self, Display}, - io, - ops::Deref, -}; -use thiserror::Error; - -/// Kinds of errors -#[derive(Copy, Clone, Debug, Eq, Error, PartialEq)] -pub enum ErrorKind { - /// Error in configuration file - #[error("config error")] - Config, - - /// Input/output error - #[error("I/O error")] - Io, -} - -impl ErrorKind { - /// Create an error context from this error - pub fn context(self, source: impl Into) -> Context { - Context::new(self, Some(source.into())) - } -} - -/// Error type -#[derive(Debug)] -pub struct Error(Box>); - -impl Deref for Error { - type Target = Context; - - fn deref(&self) -> &Context { - &self.0 - } -} - -impl Display for Error { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - self.0.fmt(f) - } -} - -impl std::error::Error for Error { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - self.0.source() - } -} - -impl From for Error { - fn from(kind: ErrorKind) -> Self { - Context::new(kind, None).into() - } -} - -impl From> for Error { - fn from(context: Context) -> Self { - Error(Box::new(context)) - } -} - -impl From for Error { - fn from(err: io::Error) -> Self { - ErrorKind::Io.context(err).into() - } -} diff --git a/vers-cli/src/errors.rs b/vers-cli/src/errors.rs new file mode 100644 index 0000000..c255539 --- /dev/null +++ b/vers-cli/src/errors.rs @@ -0,0 +1,6 @@ +use thiserror::Error; + +pub type Result = std::result::Result; + +#[derive(Debug, Clone, Error)] +pub enum CliError {} diff --git a/vers-cli/src/lib.rs b/vers-cli/src/lib.rs deleted file mode 100644 index d1c98b3..0000000 --- a/vers-cli/src/lib.rs +++ /dev/null @@ -1,22 +0,0 @@ -//! VersCli -//! -//! Application based on the [Abscissa] framework. -//! -//! [Abscissa]: https://github.com/iqlusioninc/abscissa - -// Tip: Deny warnings with `RUSTFLAGS="-D warnings"` environment variable in CI - -#![forbid(unsafe_code)] -#![warn( - missing_docs, - rust_2018_idioms, - trivial_casts, - unused_lifetimes, - unused_qualifications -)] - -pub mod application; -pub mod commands; -pub mod config; -pub mod error; -pub mod prelude; diff --git a/vers-cli/src/main.rs b/vers-cli/src/main.rs new file mode 100644 index 0000000..06cfd5b --- /dev/null +++ b/vers-cli/src/main.rs @@ -0,0 +1,28 @@ +mod cli; +mod cmds; +mod errors; + +use crate::{cli::*, errors::*}; +use anyhow::Result; +use directories_next::ProjectDirs; +use vers_core::{environment::Environment, machine::Details}; + +fn main() -> Result<()> { + let cli = Cli::new()?; + eprintln!("{:?}", &cli); + + let os_details = Details::get()?; + eprintln!("{:?}", &os_details); + + let project_directories = ProjectDirs::from("dev", "reynn", "vers").unwrap(); + let data_directory = project_directories.data_local_dir(); + let env_directory = data_directory.join("envs"); + let env_dir = env_directory.to_str().unwrap(); + + let mut env = Environment::new(&cli.env_name)?; + // let env = env.base_directory(env_dir); + + eprintln!("{:?}", &env); + + Ok(()) +} diff --git a/vers-cli/src/prelude.rs b/vers-cli/src/prelude.rs deleted file mode 100644 index b22d022..0000000 --- a/vers-cli/src/prelude.rs +++ /dev/null @@ -1,9 +0,0 @@ -//! Application-local prelude: conveniently import types/functions/macros -//! which are generally useful and should be available in every module with -//! `use crate::prelude::*; - -/// Abscissa core prelude -pub use abscissa_core::prelude::*; - -/// Application state accessors -pub use crate::application::{app_config, app_reader, app_writer}; diff --git a/vers-cli/tests/acceptance.rs b/vers-cli/tests/acceptance.rs deleted file mode 100644 index 0b2f692..0000000 --- a/vers-cli/tests/acceptance.rs +++ /dev/null @@ -1,91 +0,0 @@ -//! Acceptance test: runs the application as a subprocess and asserts its -//! output for given argument combinations matches what is expected. -//! -//! Modify and/or delete these as you see fit to test the specific needs of -//! your application. -//! -//! For more information, see: -//! - -// Tip: Deny warnings with `RUSTFLAGS="-D warnings"` environment variable in CI - -#![forbid(unsafe_code)] -#![warn( - missing_docs, - rust_2018_idioms, - trivial_casts, - unused_lifetimes, - unused_qualifications -)] - -use abscissa_core::testing::prelude::*; -use once_cell::sync::Lazy; -use vers::config::VersCliConfig; - -/// Executes your application binary via `cargo run`. -/// -/// Storing this value as a [`Lazy`] static ensures that all instances of -/// the runner acquire a mutex when executing commands and inspecting -/// exit statuses, serializing what would otherwise be multithreaded -/// invocations as `cargo test` executes tests in parallel by default. -pub static RUNNER: Lazy = Lazy::new(|| CmdRunner::default()); - -/// Use `VersCliConfig::default()` value if no config or args -#[test] -fn start_no_args() { - let mut runner = RUNNER.clone(); - let mut cmd = runner.arg("start").capture_stdout().run(); - cmd.stdout().expect_line("Hello, world!"); - cmd.wait().unwrap().expect_success(); -} - -/// Use command-line argument value -#[test] -fn start_with_args() { - let mut runner = RUNNER.clone(); - let mut cmd = runner - .args(&["start", "acceptance", "test"]) - .capture_stdout() - .run(); - - cmd.stdout().expect_line("Hello, acceptance test!"); - cmd.wait().unwrap().expect_success(); -} - -/// Use configured value -#[test] -fn start_with_config_no_args() { - let mut config = VersCliConfig::default(); - config.hello.recipient = "configured recipient".to_owned(); - let expected_line = format!("Hello, {}!", &config.hello.recipient); - - let mut runner = RUNNER.clone(); - let mut cmd = runner.config(&config).arg("start").capture_stdout().run(); - cmd.stdout().expect_line(&expected_line); - cmd.wait().unwrap().expect_success(); -} - -/// Override configured value with command-line argument -#[test] -fn start_with_config_and_args() { - let mut config = VersCliConfig::default(); - config.hello.recipient = "configured recipient".to_owned(); - - let mut runner = RUNNER.clone(); - let mut cmd = runner - .config(&config) - .args(&["start", "acceptance", "test"]) - .capture_stdout() - .run(); - - cmd.stdout().expect_line("Hello, acceptance test!"); - cmd.wait().unwrap().expect_success(); -} - -/// Example of a test which matches a regular expression -#[test] -fn version_no_args() { - let mut runner = RUNNER.clone(); - let mut cmd = runner.arg("version").capture_stdout().run(); - cmd.stdout().expect_regex(r"\A\w+ [\d\.\-]+\z"); -} diff --git a/vers-core/Cargo.toml b/vers-core/Cargo.toml index bc616ff..d466c69 100644 --- a/vers-core/Cargo.toml +++ b/vers-core/Cargo.toml @@ -1,13 +1,15 @@ [package] -name = "vers-core" -version = "0.1.0" authors = ["Nic Patterson "] edition = "2018" +name = "vers-core" +version = "0.1.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -thiserror = "1.0" -log = "0.4" -async_trait = "0.1" - +async-trait = "0.1" +log = "0.4" +serde = { version = "1.0", features = ["derive"] } +thiserror = "1.0" +toml = "0.5" +url = "2.2" diff --git a/vers-core/src/arch.rs b/vers-core/src/arch.rs deleted file mode 100644 index ad4328f..0000000 --- a/vers-core/src/arch.rs +++ /dev/null @@ -1,43 +0,0 @@ -use thiserror::Error; - -#[derive(Debug, Clone, PartialEq, Eq)] -pub enum Arch { - X86_64, - X86, - Aarch64, - Armv7, - PowerPc, - Mips, - Mips64, -} - -type Result = std::result::Result; - -impl Arch { - pub fn parse<'s>(s: &'s str) -> Result { - match s.to_lowercase().as_str() { - "x86_64" | "amd64" => Ok(Self::X86_64), - "x86" | "i686" => Ok(Self::X86), - _ => Err(ArchError::UnknownArch(s.to_owned())), - } - } -} - -#[derive(Debug, Clone, Error)] -pub enum ArchError { - #[error("Failed to determine appropriate architecture, provided {0}")] - UnknownArch(String), -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_arch_parse() -> Result<(), Box> { - let arch = Arch::parse("amd64")?; - assert_eq!(arch, Arch::X86_64); - - Ok(()) - } -} diff --git a/vers-core/src/environment/errors.rs b/vers-core/src/environment/errors.rs new file mode 100644 index 0000000..2cbeb76 --- /dev/null +++ b/vers-core/src/environment/errors.rs @@ -0,0 +1,25 @@ +use thiserror::Error; + +pub type Result = std::result::Result; + +#[derive(Debug, Error)] +pub enum EnvironmentError { + #[error("I/O Error: {0}")] + IoError(#[from] std::io::Error), + #[error("Discovered OS is not recognized: {0}")] + UnknownOs(String), + #[error("Failed to determine appropriate architecture, provided {0}")] + UnknownArch(String), + #[error("Environment named {0} not found")] + EnvironmentNotFoundByName(String), + #[error("No environments with tool: {0}, not found")] + EnvironmentNotFoundByTool(String), + #[error("General Environment error: {0}")] + General(String), +} + +impl From<&str> for EnvironmentError { + fn from(s: &str) -> Self { + Self::General(s.to_owned()) + } +} diff --git a/vers-core/src/environment/mod.rs b/vers-core/src/environment/mod.rs new file mode 100644 index 0000000..0243d94 --- /dev/null +++ b/vers-core/src/environment/mod.rs @@ -0,0 +1,97 @@ +mod errors; +mod tool; + +use log::*; +use std::path::{Path, PathBuf}; + +pub use self::{errors::*, tool::Tool}; + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Environment<'env> { + name: &'env str, + tools: Vec<&'env Tool<'env>>, + directory: Option, +} + +impl<'env> Drop for Environment<'env> { + fn drop(&mut self) { + self.save().unwrap(); + } +} + +impl<'builder> Environment<'builder> { + pub fn base_directory(&mut self, dir: &'builder str) -> &'builder Environment { + let dir = Path::new(dir); + self.directory = Some(dir.join(self.name)); + self + } + + pub fn add_tool(&mut self, tool: &'builder Tool<'_>) -> &'builder Environment { + self.tools.push(tool); + self + } + + pub fn save(&self) -> Result<&'builder Environment> { + if let Some(dir) = &self.directory { + std::fs::create_dir_all(dir)?; + } + Ok(self) + } +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum EnvFindOptions<'find_tool> { + Name(String), + Tool(Tool<'find_tool>), +} + +impl<'env> Environment<'env> { + /// + pub fn new(name: &'env str) -> Result> { + Ok(Self { + name, + tools: Vec::new(), + directory: None, + }) + } + + /// + pub fn find_envs(f: &'_ EnvFindOptions, base_path: &Path) -> Result>> { + match f { + EnvFindOptions::Name(s) => Ok(vec![Self::find_env_by_name(s, base_path)?]), + EnvFindOptions::Tool(t) => Self::find_envs_by_tool(t, base_path), // _ => Err(EnvironmentError::General("".into())), + } + } + + /// Attempts to find an existing [`Environment`] + /// + /// If unable to find an environment in the provided base path, + /// returns a [`EnvironmentError::EnvironmentNotFoundByName`] + fn find_env_by_name(s: &'_ str, base_path: &Path) -> Result> { + // base_path + // .read_dir() + // .expect("read_dir call failed") + // .filter(|entry| { + // if let Ok(entry) = entry { + // println!("{:?}", entry.path()); + // } + // }) + Err(EnvironmentError::EnvironmentNotFoundByName(s.into())) + } + + /// Attempts to find existing [`Environment`]s that contain a tool, if a tool is provided will only return + /// + fn find_envs_by_tool(t: &'_ Tool, base_path: &Path) -> Result>> { + Err(EnvironmentError::EnvironmentNotFoundByTool(t.name.into())) + } + + // fn get_environments() -> Result>> { + // Ok() + // } +} + +impl<'env> Default for Environment<'env> { + fn default() -> Self { + Self::new("default").unwrap() + } +} diff --git a/vers-core/src/environment/tool.rs b/vers-core/src/environment/tool.rs new file mode 100644 index 0000000..fa48cb4 --- /dev/null +++ b/vers-core/src/environment/tool.rs @@ -0,0 +1,8 @@ +use crate::release::Release; + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Tool<'t> { + pub name: &'t str, + pub current_release: Option<&'t Release>, + pub installed_releases: Option>, +} diff --git a/vers-core/src/envs.rs b/vers-core/src/envs.rs deleted file mode 100644 index e69de29..0000000 diff --git a/vers-core/src/errors.rs b/vers-core/src/errors.rs new file mode 100644 index 0000000..104a74b --- /dev/null +++ b/vers-core/src/errors.rs @@ -0,0 +1,22 @@ +use super::{environment::EnvironmentError, machine::MachineError}; +pub use thiserror::Error; + +pub type Result = std::result::Result; + +#[derive(Debug, Error)] +pub enum VersCoreError { + #[error("Failed to find an existing environment with the name {0}")] + EnvFindError(String), + #[error("General error in core: {0}")] + General(String), + #[error("{0}")] + MachineError(#[from] MachineError), + #[error("{0}")] + EnvironmentError(#[from] EnvironmentError), +} + +impl From<&str> for VersCoreError { + fn from(s: &str) -> Self { + Self::General(s.to_owned()) + } +} diff --git a/vers-core/src/filters.rs b/vers-core/src/filters.rs index 7121b1c..8b13789 100644 --- a/vers-core/src/filters.rs +++ b/vers-core/src/filters.rs @@ -1 +1 @@ -use crate::os::Os; + diff --git a/vers-core/src/lib.rs b/vers-core/src/lib.rs index 48fd5e2..d985227 100644 --- a/vers-core/src/lib.rs +++ b/vers-core/src/lib.rs @@ -1,6 +1,29 @@ -mod arch; -mod envs; -mod filters; -mod manager; -mod os; -mod release; +// Require docs for public APIs, deny unsafe code, etc. +// #![forbid(unsafe_code, unused_must_use, unstable_features)] +// #![deny( +// clippy::clone_on_ref_ptr, +// trivial_casts, +// trivial_numeric_casts, +// missing_docs, +// unreachable_pub, +// unused_import_braces, +// unused_extern_crates, +// unused_qualifications +// )] + +/// Environments help group usable tools together, this can be helpful for workflows where you need to keep +/// mutlple versions of the same tool, for instance multiple different versions of `kubectl` to connect to +/// legacy clusters and new clusters +pub mod environment; +/// TODO: write docs +pub mod errors; +/// TODO: write docs +pub mod filters; +/// TODO: write docs +pub mod machine; +/// TODO: write docs +pub mod manager; +/// TODO: write docs +pub mod release; +/// TODO: write docs +pub mod version; diff --git a/vers-core/src/machine/arch.rs b/vers-core/src/machine/arch.rs new file mode 100644 index 0000000..cf7c16f --- /dev/null +++ b/vers-core/src/machine/arch.rs @@ -0,0 +1,39 @@ +use super::errors::*; + +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum Arch { + X86_64, + X86, + Aarch64, + Armv7, + PowerPc, + Mips, + Mips64, +} + +impl Arch { + pub fn get() -> Result { + Ok(Arch::X86_64) + } + + pub fn parse(s: &'_ str) -> Result { + match s.to_lowercase().as_str() { + "x86_64" | "amd64" => Ok(Self::X86_64), + "x86" | "i686" => Ok(Self::X86), + _ => Err(MachineError::UnknownArch(s.to_owned())), + } + } +} + +// #[cfg(test)] +// mod tests { +// use super::*; + +// #[test] +// fn test_arch_parse() -> Result<(), Box> { +// let arch = Arch::parse("amd64")?; +// assert_eq!(arch, Arch::X86_64); + +// Ok(()) +// } +// } diff --git a/vers-core/src/machine/errors.rs b/vers-core/src/machine/errors.rs new file mode 100644 index 0000000..8299d40 --- /dev/null +++ b/vers-core/src/machine/errors.rs @@ -0,0 +1,11 @@ +use thiserror::Error; + +pub type Result = std::result::Result; + +#[derive(Debug, Clone, Error)] +pub enum MachineError { + #[error("Discovered OS is not recognized: {0}")] + UnknownOs(String), + #[error("Failed to determine appropriate architecture, provided {0}")] + UnknownArch(String), +} diff --git a/vers-core/src/machine/mod.rs b/vers-core/src/machine/mod.rs new file mode 100644 index 0000000..4f4675e --- /dev/null +++ b/vers-core/src/machine/mod.rs @@ -0,0 +1,60 @@ +pub(crate) mod arch; +pub(crate) mod errors; +pub(crate) mod os; +pub(crate) mod os_version; + +use self::{arch::Arch, os::Os, os_version::OsVersion}; +pub use errors::*; + +#[derive(Debug, Clone)] +pub struct Details { + pub os: Os, + pub os_version: OsVersion, + pub arch: Arch, +} + +impl Details { + pub fn get() -> Result
{ + Ok(Details { + os: Self::get_os_details()?, + os_version: Self::get_os_version()?, + arch: Self::get_arch()?, + }) + } + + fn get_os_details() -> Result { + Os::get() + } + + fn get_arch() -> Result { + Arch::get() + } + + fn get_os_version() -> Result { + OsVersion::get() + } +} + +// #[cfg(test)] +// mod tests { +// use super::*; + +// #[test] +// fn test_os_parse() { +// let os = Os::parse("windows").expect("Windows was not a recognized OS"); +// assert_eq!(os, Os::Windows); +// let os = Os::parse("linux").expect("Linux was not a recognized OS"); +// assert_eq!(os, Os::Linux); +// let os = Os::parse("mac").expect("Mac was not a recognized OS"); +// assert_eq!(os, Os::Osx); +// let os = Os::parse("osx").expect("Mac was not a recognized OS"); +// assert_eq!(os, Os::Osx); +// } + +// #[test] +// fn test_get_os_details() { +// let os_details = Details::get().expect("Failed to get the details for current machine"); +// assert_eq!(&os_details.os, &Os::Linux); +// assert_eq!(&os_details.arch, &Arch::X86_64); +// } +// } diff --git a/vers-core/src/machine/os.rs b/vers-core/src/machine/os.rs new file mode 100644 index 0000000..56e59da --- /dev/null +++ b/vers-core/src/machine/os.rs @@ -0,0 +1,30 @@ +use super::errors::*; + +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub enum Os { + Windows, + Linux, + Osx, +} + +impl Os { + pub fn get() -> Result { + let os = if cfg!(windows) { + Os::Windows + } else if cfg!(linux) { + Os::Linux + } else { + Os::Osx + }; + Ok(os) + } + + pub fn parse(s: &'_ str) -> Result { + match s.to_lowercase().as_str() { + "windows" => Ok(Self::Windows), + "linux" => Ok(Self::Linux), + "mac" | "osx" => Ok(Self::Osx), + _ => Err(MachineError::UnknownOs(s.to_owned())), + } + } +} diff --git a/vers-core/src/machine/os_version.rs b/vers-core/src/machine/os_version.rs new file mode 100644 index 0000000..5adc33b --- /dev/null +++ b/vers-core/src/machine/os_version.rs @@ -0,0 +1,12 @@ +use super::errors::*; + +#[derive(Debug, Clone)] +pub struct OsVersion { + // variant: String, +} + +impl OsVersion { + pub fn get() -> Result { + Ok(Self {}) + } +} diff --git a/vers-core/src/manager.rs b/vers-core/src/manager.rs index 34fb90c..c9e90b3 100644 --- a/vers-core/src/manager.rs +++ b/vers-core/src/manager.rs @@ -1,14 +1,39 @@ -use async_trait::async_trait; -use thiserror::Error; +pub use async_trait::async_trait; -use crate::release::Release; +use crate::{errors::*, machine::Details}; +use url::Url; #[async_trait] pub trait Manager { - async fn list(lt: &ListType) -> Result<(), ManagerError>; - async fn install() -> Result<(), ManagerError>; - async fn update() -> Result<(), ManagerError>; - async fn delete() -> Result<(), ManagerError>; + async fn list_releases() -> Result<()>; + async fn list_assets() -> Result<()>; + async fn install_release(machine: &'_ Details) -> Result<()>; + async fn update() -> Result<()>; + async fn delete() -> Result<()>; +} + +#[derive(Debug, Clone)] +pub enum Assets { + GitHubReleaseAsset { remote_url: Url }, + None, +} + +#[derive(Debug, Clone)] +pub struct GitHubReleaseManager { + host: String, + auth: GitHubAuth, +} + +#[derive(Debug, Clone)] +pub enum GitHubAuth { + ApiToken(String), + Public, +} + +impl Default for GitHubAuth { + fn default() -> Self { + Self::Public + } } #[derive(Debug, Clone)] @@ -16,6 +41,3 @@ pub enum ListType { Local, Remote(String), } - -#[derive(Debug, Clone, Error)] -pub enum ManagerError {} diff --git a/vers-core/src/os.rs b/vers-core/src/os.rs deleted file mode 100644 index f643df0..0000000 --- a/vers-core/src/os.rs +++ /dev/null @@ -1,51 +0,0 @@ -use std::fmt::Display; -use thiserror::Error; - -#[derive(Debug, PartialEq, Eq, Hash)] -pub enum Os { - Windows, - Linux, - Osx, -} - -impl Display for Os { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self) - } -} - -impl Os { - pub fn parse<'a>(s: &'a str) -> Result { - match s.to_lowercase().as_str() { - "windows" => Ok(Self::Windows), - "linux" => Ok(Self::Linux), - "mac" | "osx" => Ok(Self::Osx), - _ => Err(OsErrror::UnknownOs(s.to_owned())), - } - } -} - -type Result = std::result::Result; - -#[derive(Debug, Clone, Error)] -pub enum OsErrror { - #[error("Discovered OS is not recognized: {0}")] - UnknownOs(String), -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_os_parse() { - let os = Os::parse("windows").expect("Windows was not a recognized OS"); - assert_eq!(os, Os::Windows); - let os = Os::parse("linux").expect("Linux was not a recognized OS"); - assert_eq!(os, Os::Linux); - let os = Os::parse("mac").expect("Mac was not a recognized OS"); - assert_eq!(os, Os::Osx); - let os = Os::parse("osx").expect("Mac was not a recognized OS"); - assert_eq!(os, Os::Osx); - } -} diff --git a/vers-core/src/release.rs b/vers-core/src/release.rs index 1884e37..2aff170 100644 --- a/vers-core/src/release.rs +++ b/vers-core/src/release.rs @@ -1,8 +1,8 @@ -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Release {} -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Asset {} -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum ReleaseError {} diff --git a/vers-core/src/version.rs b/vers-core/src/version.rs new file mode 100644 index 0000000..eb9398a --- /dev/null +++ b/vers-core/src/version.rs @@ -0,0 +1,48 @@ +use crate::errors::*; + +#[derive(Debug, Clone)] +pub enum VersionType { + SemVer { + major: i8, + minor: i8, + patch: i8, + pre_release: Option, + build: Option, + }, + Uknown(String), +} + +impl VersionType { + pub fn parse(s: &'_ str) -> Result { + Ok(VersionType::Uknown(s.to_owned())) + } +} + +#[derive(Debug, Clone)] +pub enum Version { + Latest, + Specific(VersionType), + Stable, + PreRelease, +} + +impl Version { + pub fn parse(s: &str) -> Result { + match s { + "" => Ok(Version::Specific(VersionType::parse(s)?)), + _ => Ok(Version::Latest), + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_semver_parse() { + let v = Version::parse("0.1.0-alpha+fd3f4b7a5a331a2384ed13fb3ead44e975438c3b") + .expect("Semver parse failed"); + dbg!(v); + } +}