Use dns_common library (#818)

This commit is contained in:
Denis Isidoro 2023-04-08 19:38:50 -03:00 committed by GitHub
parent 8cf9c96e54
commit b56d70a6ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 195 additions and 57 deletions

196
Cargo.lock generated
View file

@ -218,6 +218,32 @@ dependencies = [
"winapi", "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]] [[package]]
name = "edit" name = "edit"
version = "0.1.4" version = "0.1.4"
@ -374,6 +400,15 @@ dependencies = [
"cfg-if", "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]] [[package]]
name = "memchr" name = "memchr"
version = "2.4.0" version = "2.4.0"
@ -400,6 +435,8 @@ dependencies = [
"clap", "clap",
"crossterm", "crossterm",
"directories-next", "directories-next",
"dns_common",
"dns_common_derive",
"edit", "edit",
"lazy_static", "lazy_static",
"regex", "regex",
@ -434,10 +471,26 @@ dependencies = [
] ]
[[package]] [[package]]
name = "once_cell" name = "nu-ansi-term"
version = "1.12.0" version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index" 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]] [[package]]
name = "parking_lot" name = "parking_lot"
@ -462,6 +515,12 @@ dependencies = [
"windows-sys 0.32.0", "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]] [[package]]
name = "ppv-lite86" name = "ppv-lite86"
version = "0.2.10" version = "0.2.10"
@ -556,6 +615,15 @@ dependencies = [
"regex-syntax", "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]] [[package]]
name = "regex-syntax" name = "regex-syntax"
version = "0.6.29" version = "0.6.29"
@ -642,6 +710,17 @@ dependencies = [
"syn 2.0.13", "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]] [[package]]
name = "serde_yaml" name = "serde_yaml"
version = "0.9.21" version = "0.9.21"
@ -655,6 +734,15 @@ dependencies = [
"unsafe-libyaml", "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]] [[package]]
name = "shellwords" name = "shellwords"
version = "1.1.0" version = "1.1.0"
@ -697,9 +785,9 @@ dependencies = [
[[package]] [[package]]
name = "smallvec" name = "smallvec"
version = "1.6.1" version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
[[package]] [[package]]
name = "smart-default" name = "smart-default"
@ -709,7 +797,7 @@ checksum = "133659a15339456eeeb07572eb02a91c91e9815e9cbc89566944d2c8d3efdbf6"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 1.0.94", "syn 1.0.109",
] ]
[[package]] [[package]]
@ -741,13 +829,13 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.94" version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a07e33e919ebcd69113d5be0e4d70c5707004ff45188910106854f38b960df4a" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"unicode-xid", "unicode-ident",
] ]
[[package]] [[package]]
@ -761,6 +849,18 @@ dependencies = [
"unicode-ident", "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]] [[package]]
name = "tempfile" name = "tempfile"
version = "3.2.0" version = "3.2.0"
@ -795,6 +895,78 @@ dependencies = [
"syn 2.0.13", "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]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.8" version = "1.0.8"
@ -819,6 +991,12 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
[[package]]
name = "valuable"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
[[package]] [[package]]
name = "vte" name = "vte"
version = "0.10.1" version = "0.10.1"

View file

@ -33,6 +33,8 @@ edit = "0.1.4"
remove_dir_all = "0.8.2" remove_dir_all = "0.8.2"
serde = { version = "1.0.159", features = ["derive"] } serde = { version = "1.0.159", features = ["derive"] }
serde_yaml = "0.9.21" 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] [lib]
name = "navi" name = "navi"

View file

@ -1,4 +1,4 @@
use super::prelude::*; use crate::prelude::*;
use remove_dir_all::remove_dir_all; use remove_dir_all::remove_dir_all;
use std::ffi::OsStr; use std::ffi::OsStr;
use std::fs::{self, create_dir_all, File}; use std::fs::{self, create_dir_all, File};
@ -21,14 +21,6 @@ impl ToStringExt for OsStr {
} }
} }
// pub fn config_dir(project_name: &str) -> Result<PathBuf> {
// 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)] #[derive(Error, Debug)]
#[error("Invalid path `{0}`")] #[error("Invalid path `{0}`")]
pub struct InvalidPath(pub PathBuf); pub struct InvalidPath(pub PathBuf);

View file

@ -1,13 +1,7 @@
// pub mod component;
// pub mod deps;
// pub mod deser;
pub mod clipboard; pub mod clipboard;
pub mod fs; pub mod fs;
pub mod git; pub mod git;
pub mod hash; pub mod hash;
pub mod prelude;
pub mod shell; pub mod shell;
pub mod terminal; pub mod terminal;
pub mod url; pub mod url;
// pub mod system;
// pub mod tracing;

View file

@ -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;
*/

View file

@ -1,6 +1,6 @@
use crate::commands; use crate::commands;
use crate::finder::FinderChoice; use crate::finder::FinderChoice;
use crate::prelude::*;
use clap::{crate_version, Parser, Subcommand}; use clap::{crate_version, Parser, Subcommand};
#[derive(Debug, Parser)] #[derive(Debug, Parser)]

View file

@ -1,8 +1,9 @@
pub use crate::common::prelude::*;
pub use crate::config::CONFIG; // TODO pub use crate::config::CONFIG; // TODO
pub use dns_common::prelude::*;
pub use regex::Regex; pub use regex::Regex;
pub use std::io::{BufRead, BufReader};
// pub use crate::common::fs::pathbuf_to_string; // TODO pub use std::process::Stdio;
pub use std::str::FromStr;
pub trait Runnable { pub trait Runnable {
fn run(&self) -> Result<()>; fn run(&self) -> Result<()>;