From b56d70a6ca099fb3670fb5dcd4ac43cca6f72fc5 Mon Sep 17 00:00:00 2001 From: Denis Isidoro Date: Sat, 8 Apr 2023 19:38:50 -0300 Subject: [PATCH] Use dns_common library (#818) --- Cargo.lock | 196 ++++++++++++++++++++++++++++++++++++++++-- Cargo.toml | 2 + src/common/fs.rs | 10 +-- src/common/mod.rs | 6 -- src/common/prelude.rs | 29 ------- src/config/cli.rs | 2 +- src/prelude.rs | 7 +- 7 files changed, 195 insertions(+), 57 deletions(-) delete mode 100644 src/common/prelude.rs diff --git a/Cargo.lock b/Cargo.lock index 6574d4f..e0f3fa5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -218,6 +218,32 @@ dependencies = [ "winapi", ] +[[package]] +name = "dns_common" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b06d76c4e8232fca4c777372c75fc21908eb7825c720f49657bd8936d2f4b70c" +dependencies = [ + "anyhow", + "directories-next", + "serde", + "serde_json", + "serde_yaml", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "dns_common_derive" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e8f2adde7ad6c4595b281a5a3ec5a329c2eadf8a0df536f5b977d36bc3808d0" +dependencies = [ + "proc-macro2", + "quote", + "synstructure", +] + [[package]] name = "edit" version = "0.1.4" @@ -374,6 +400,15 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata", +] + [[package]] name = "memchr" version = "2.4.0" @@ -400,6 +435,8 @@ dependencies = [ "clap", "crossterm", "directories-next", + "dns_common", + "dns_common_derive", "edit", "lazy_static", "regex", @@ -434,10 +471,26 @@ dependencies = [ ] [[package]] -name = "once_cell" -version = "1.12.0" +name = "nu-ansi-term" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + +[[package]] +name = "once_cell" +version = "1.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "parking_lot" @@ -462,6 +515,12 @@ dependencies = [ "windows-sys 0.32.0", ] +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + [[package]] name = "ppv-lite86" version = "0.2.10" @@ -556,6 +615,15 @@ dependencies = [ "regex-syntax", ] +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax", +] + [[package]] name = "regex-syntax" version = "0.6.29" @@ -642,6 +710,17 @@ dependencies = [ "syn 2.0.13", ] +[[package]] +name = "serde_json" +version = "1.0.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d721eca97ac802aa7777b701877c8004d950fc142651367300d21c1cc0194744" +dependencies = [ + "itoa", + "ryu", + "serde", +] + [[package]] name = "serde_yaml" version = "0.9.21" @@ -655,6 +734,15 @@ dependencies = [ "unsafe-libyaml", ] +[[package]] +name = "sharded-slab" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +dependencies = [ + "lazy_static", +] + [[package]] name = "shellwords" version = "1.1.0" @@ -697,9 +785,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.6.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "smart-default" @@ -709,7 +797,7 @@ checksum = "133659a15339456eeeb07572eb02a91c91e9815e9cbc89566944d2c8d3efdbf6" dependencies = [ "proc-macro2", "quote", - "syn 1.0.94", + "syn 1.0.109", ] [[package]] @@ -741,13 +829,13 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.94" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a07e33e919ebcd69113d5be0e4d70c5707004ff45188910106854f38b960df4a" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] @@ -761,6 +849,18 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", + "unicode-xid", +] + [[package]] name = "tempfile" version = "3.2.0" @@ -795,6 +895,78 @@ dependencies = [ "syn 2.0.13", ] +[[package]] +name = "thread_local" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "tracing-core" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + [[package]] name = "unicode-ident" version = "1.0.8" @@ -819,6 +991,12 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "vte" version = "0.10.1" diff --git a/Cargo.toml b/Cargo.toml index e12a65b..dacbc1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,8 @@ edit = "0.1.4" remove_dir_all = "0.8.2" serde = { version = "1.0.159", features = ["derive"] } serde_yaml = "0.9.21" +dns_common_derive = { version = "0.2.1" } +dns_common = { version = "0.2.1", default-features = false, features = ["yaml", "json"] } [lib] name = "navi" diff --git a/src/common/fs.rs b/src/common/fs.rs index 89f6275..32c8b1e 100644 --- a/src/common/fs.rs +++ b/src/common/fs.rs @@ -1,4 +1,4 @@ -use super::prelude::*; +use crate::prelude::*; use remove_dir_all::remove_dir_all; use std::ffi::OsStr; use std::fs::{self, create_dir_all, File}; @@ -21,14 +21,6 @@ impl ToStringExt for OsStr { } } -// pub fn config_dir(project_name: &str) -> Result { -// let base_dirs = BaseDirs::new().context("unable to get base dirs")?; -// -// let mut pathbuf = PathBuf::from(base_dirs.config_dir()); -// pathbuf.push(project_name); -// Ok(pathbuf) -// } - #[derive(Error, Debug)] #[error("Invalid path `{0}`")] pub struct InvalidPath(pub PathBuf); diff --git a/src/common/mod.rs b/src/common/mod.rs index 1ea86d1..395dd48 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -1,13 +1,7 @@ -// pub mod component; -// pub mod deps; -// pub mod deser; pub mod clipboard; pub mod fs; pub mod git; pub mod hash; -pub mod prelude; pub mod shell; pub mod terminal; pub mod url; -// pub mod system; -// pub mod tracing; diff --git a/src/common/prelude.rs b/src/common/prelude.rs deleted file mode 100644 index 7393924..0000000 --- a/src/common/prelude.rs +++ /dev/null @@ -1,29 +0,0 @@ -// pub use super::component::Component; -// pub use super::deps::HasDeps; -pub use super::fs::ToStringExt; -pub use anyhow::{anyhow, Context, Error, Result}; -pub use serde::de::Deserializer; -pub use serde::ser::Serializer; -pub use serde::{Deserialize, Serialize}; -pub use std::any::{Any, TypeId}; -pub use std::collections::{HashMap, HashSet}; -pub use std::convert::{TryFrom, TryInto}; -pub use std::fmt::Debug; -pub use std::fs::File; -pub use std::io::{BufRead, BufReader}; -pub use std::path::{Path, PathBuf}; -pub use std::process::Stdio; -pub use std::str::FromStr; -pub use std::sync::{Arc, Mutex, RwLock}; -// pub use tracing::{self, debug, error, event, info, instrument, span, trace, warn}; -/* -pub extern crate anyhow; -pub extern crate serde; -pub extern crate tracing_subscriber; - -#[cfg(feature = "yaml")] -pub extern crate serde_yaml; - -#[cfg(feature = "json")] -pub extern crate serde_json; - */ diff --git a/src/config/cli.rs b/src/config/cli.rs index 646fe96..431b1da 100644 --- a/src/config/cli.rs +++ b/src/config/cli.rs @@ -1,6 +1,6 @@ use crate::commands; use crate::finder::FinderChoice; -use crate::prelude::*; + use clap::{crate_version, Parser, Subcommand}; #[derive(Debug, Parser)] diff --git a/src/prelude.rs b/src/prelude.rs index bfe6124..709624d 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -1,8 +1,9 @@ -pub use crate::common::prelude::*; pub use crate::config::CONFIG; // TODO +pub use dns_common::prelude::*; pub use regex::Regex; - -// pub use crate::common::fs::pathbuf_to_string; // TODO +pub use std::io::{BufRead, BufReader}; +pub use std::process::Stdio; +pub use std::str::FromStr; pub trait Runnable { fn run(&self) -> Result<()>;