From ddeef50c56ab3c2636d89b364eaf1310a3236e3d Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Sat, 29 Jul 2023 12:42:48 +0800 Subject: [PATCH 1/3] Remove need for lazy_static in cli --- Cargo.lock | 1 - butane_cli/Cargo.toml | 3 +-- butane_cli/src/main.rs | 5 +---- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dc63740c..6724778c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -262,7 +262,6 @@ dependencies = [ "cargo_metadata", "chrono", "clap", - "lazy_static", "quote 1.0.32", "serde", "serde_json", diff --git a/butane_cli/Cargo.toml b/butane_cli/Cargo.toml index 17709dd0..209e70de 100644 --- a/butane_cli/Cargo.toml +++ b/butane_cli/Cargo.toml @@ -24,8 +24,7 @@ anyhow = "1.0" butane = { features = ["default", "pg", "sqlite"], workspace = true } cargo_metadata = "0.17" chrono = { workspace = true } -clap = { version = "4.1" } -lazy_static = "1.4" +clap = { version = "4.1", features = ["string"] } quote = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } diff --git a/butane_cli/src/main.rs b/butane_cli/src/main.rs index a3b1ad51..4885d680 100644 --- a/butane_cli/src/main.rs +++ b/butane_cli/src/main.rs @@ -8,9 +8,6 @@ use butane_cli::{ }; fn main() { - lazy_static::lazy_static! { - static ref WORKING_DIR_PATH: PathBuf = base_dir(); - } let app = clap::Command::new("butane") .version(env!("CARGO_PKG_VERSION")) .author("James Oakley ") @@ -19,7 +16,7 @@ fn main() { .max_term_width(80) .arg( Arg::new("path").short('p').long("path") - .default_value(WORKING_DIR_PATH.as_os_str()) + .default_value(base_dir().into_os_string()) .value_parser(value_parser!(PathBuf)) .help("Select directory to locate butane state") ) From 3944f19912bbf7509e5baea00f9e9a1c77a75cb7 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Sat, 29 Jul 2023 10:36:06 +0800 Subject: [PATCH 2/3] Use clio --- butane_cli/Cargo.toml | 1 + butane_cli/src/main.rs | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/butane_cli/Cargo.toml b/butane_cli/Cargo.toml index 209e70de..860d4857 100644 --- a/butane_cli/Cargo.toml +++ b/butane_cli/Cargo.toml @@ -25,6 +25,7 @@ butane = { features = ["default", "pg", "sqlite"], workspace = true } cargo_metadata = "0.17" chrono = { workspace = true } clap = { version = "4.1", features = ["string"] } +clio = { version = "0.3.2", features = ["clap-parse"] } quote = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } diff --git a/butane_cli/src/main.rs b/butane_cli/src/main.rs index 4885d680..0b69daa1 100644 --- a/butane_cli/src/main.rs +++ b/butane_cli/src/main.rs @@ -1,6 +1,7 @@ use std::path::PathBuf; use clap::{value_parser, Arg, ArgMatches}; +use clio::ClioPath; use butane_cli::{ base_dir, clean, clear_data, collapse_migrations, delete_table, embed, handle_error, @@ -17,7 +18,7 @@ fn main() { .arg( Arg::new("path").short('p').long("path") .default_value(base_dir().into_os_string()) - .value_parser(value_parser!(PathBuf)) + .value_parser(value_parser!(ClioPath).exists().is_dir()) .help("Select directory to locate butane state") ) .subcommand( @@ -93,7 +94,7 @@ fn main() { .about("Clean current migration state. Deletes the current migration working state which is generated on each build. This can be used as a workaround to remove stale tables from the schema, as Butane does not currently auto-detect model removals. The next build will recreate with only tables for the extant models.")) .arg_required_else_help(true); let args = app.get_matches(); - let mut base_dir = args.get_one::("path").unwrap().clone(); + let mut base_dir: PathBuf = args.get_one::("path").unwrap().to_path_buf(); base_dir.push(".butane"); match args.subcommand() { Some(("init", sub_args)) => handle_error(init(&base_dir, Some(sub_args))), From 952901c7792cd86ba9624c21f1d4349283937268 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Sat, 29 Jul 2023 13:09:11 +0800 Subject: [PATCH 3/3] update lock --- Cargo.lock | 146 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 129 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6724778c..856d7228 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -94,7 +94,7 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" dependencies = [ - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -104,7 +104,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" dependencies = [ "anstyle", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -262,6 +262,7 @@ dependencies = [ "cargo_metadata", "chrono", "clap", + "clio", "quote 1.0.32", "serde", "serde_json", @@ -401,6 +402,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5fd304a20bff958a57f04c4e96a2e7594cc4490a0e809cbd48bb6437edaa452d" dependencies = [ "clap_builder", + "clap_derive", + "once_cell", ] [[package]] @@ -415,12 +418,39 @@ dependencies = [ "strsim 0.10.0", ] +[[package]] +name = "clap_derive" +version = "4.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" +dependencies = [ + "heck", + "proc-macro2 1.0.66", + "quote 1.0.32", + "syn 2.0.27", +] + [[package]] name = "clap_lex" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" +[[package]] +name = "clio" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "746ce4269bee03af43b3349f37f420cf5957f8431c531c08dea0441b298b10e0" +dependencies = [ + "cfg-if", + "clap", + "is-terminal", + "libc", + "tempfile", + "walkdir", + "windows-sys 0.42.0", +] + [[package]] name = "colorchoice" version = "1.0.0" @@ -594,7 +624,7 @@ checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ "errno-dragonfly", "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -848,6 +878,12 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "hermit-abi" version = "0.3.2" @@ -912,7 +948,7 @@ checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi", "rustix", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1022,7 +1058,7 @@ checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" dependencies = [ "libc", "wasi", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1443,7 +1479,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1452,13 +1488,22 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "schannel" version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" dependencies = [ - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1594,7 +1639,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1666,7 +1711,7 @@ dependencies = [ "fastrand", "redox_syscall", "rustix", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1732,7 +1777,7 @@ dependencies = [ "mio", "pin-project-lite", "socket2 0.4.9", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1881,6 +1926,16 @@ dependencies = [ "libc", ] +[[package]] +name = "walkdir" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -1981,6 +2036,21 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -1996,51 +2066,93 @@ version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" 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", + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + [[package]] name = "windows_aarch64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + [[package]] name = "windows_i686_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + [[package]] name = "windows_i686_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + [[package]] name = "windows_x86_64_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + [[package]] name = "windows_x86_64_msvc" version = "0.48.0"