mirror of
https://github.com/denisidoro/navi.git
synced 2026-01-23 02:14:19 +00:00
wip
This commit is contained in:
parent
92cf10d10a
commit
fcfa7843fc
7 changed files with 58 additions and 71 deletions
55
Cargo.lock
generated
55
Cargo.lock
generated
|
|
@ -134,19 +134,6 @@ dependencies = [
|
|||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types-shared"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.1.14"
|
||||
|
|
@ -222,25 +209,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
dependencies = [
|
||||
"cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libssh2-sys 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl-sys 0.9.54 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libssh2-sys"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl-sys 0.9.54 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"vcpkg 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libz-sys"
|
||||
version = "1.0.25"
|
||||
|
|
@ -277,7 +250,6 @@ dependencies = [
|
|||
"dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"git2 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl 0.10.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"raw_tty 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"structopt 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
@ -291,32 +263,11 @@ name = "numtoa"
|
|||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "openssl"
|
||||
version = "0.10.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl-sys 0.9.54 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openssl-probe"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "openssl-src"
|
||||
version = "111.6.1+1.1.1d"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openssl-sys"
|
||||
version = "0.9.54"
|
||||
|
|
@ -325,7 +276,6 @@ dependencies = [
|
|||
"autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl-src 111.6.1+1.1.1d (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"vcpkg 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
|
@ -708,8 +658,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
"checksum derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6d944ac6003ed268757ef1ee686753b57efc5fcf0ebe7b64c9fc81e7e32ff839"
|
||||
"checksum dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3"
|
||||
"checksum dirs-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "afa0b23de8fd801745c471deffa6e12d248f962c9fd4b4c33787b055599bde7b"
|
||||
"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
|
||||
"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
|
||||
"checksum getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
|
||||
"checksum git2 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c1af51ea8a906616af45a4ce78eacf25860f7a13ae7bf8a814693f0f4037a26"
|
||||
"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
|
||||
|
|
@ -719,15 +667,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
"checksum libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)" = "eb147597cdf94ed43ab7a9038716637d2d1bf2bc571da995d0028dec06bd3018"
|
||||
"checksum libgit2-sys 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4870c781f6063efb83150cd22c1ddf6ecf58531419e7570cdcced46970f64a16"
|
||||
"checksum libssh2-sys 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)" = "7bb70f29dc7c31d32c97577f13f41221af981b31248083e347b7f2c39225a6bc"
|
||||
"checksum libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "2eb5e43362e38e2bca2fd5f5134c4d4564a23a5c28e9b95411652021a8675ebe"
|
||||
"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
|
||||
"checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
|
||||
"checksum memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
|
||||
"checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef"
|
||||
"checksum openssl 0.10.28 (registry+https://github.com/rust-lang/crates.io-index)" = "973293749822d7dd6370d6da1e523b0d1db19f06c459134c658b2a4261378b52"
|
||||
"checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"
|
||||
"checksum openssl-src 111.6.1+1.1.1d (registry+https://github.com/rust-lang/crates.io-index)" = "c91b04cb43c1a8a90e934e0cd612e2a5715d976d2d6cff4490278a0cddf35005"
|
||||
"checksum openssl-sys 0.9.54 (registry+https://github.com/rust-lang/crates.io-index)" = "1024c0a59774200a555087a6da3f253a9095a5f344e353b212ac4c8b8e450986"
|
||||
"checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
|
||||
"checksum pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677"
|
||||
|
|
|
|||
|
|
@ -19,13 +19,12 @@ raw_tty = "0.1.0"
|
|||
lazy_static = "1.4.0"
|
||||
dirs = "2.0.0"
|
||||
terminal_size = "0.1.10"
|
||||
git2 = "0.10.0"
|
||||
walkdir = "2"
|
||||
openssl = { version = '0.10', optional = true }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
vendored-openssl = ["openssl/vendored"]
|
||||
[dependencies.git2]
|
||||
version = "0.10.0"
|
||||
default-features = false
|
||||
features = ["https"]
|
||||
|
||||
[[bin]]
|
||||
bench = false
|
||||
|
|
|
|||
|
|
@ -6,7 +6,12 @@ An interactive cheatsheet tool for the command-line.
|
|||
|
||||

|
||||
|
||||
**navi** allows you to browse through cheatsheets (that you may write yourself or download from maintainers) and execute commands. Argument suggestions are prompted to you.
|
||||
**navi** allows you to browse through cheatsheets (that you may write yourself or download from maintainers) and execute commands. Argument suggestions are prompted to you.
|
||||
|
||||
It will:
|
||||
- make you type less;
|
||||
- spare you from knowing CLIs by heart;
|
||||
- teach you new one-liners.
|
||||
|
||||
It uses [fzf](https://github.com/junegunn/fzf) under the hood and it can be either used as a command or as a shell widget (*à la* Ctrl-R).
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ release() {
|
|||
|
||||
if [ -n "$target" ]; then
|
||||
cargo install cross 2> /dev/null || true
|
||||
cross build --release --locked --target "$target" --features vendored-openssl
|
||||
cross build --release --locked --target "$target"
|
||||
bin_folder="${target}/release"
|
||||
else
|
||||
cargo build --release --locked
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use crate::cheat::SuggestionType;
|
||||
use crate::filesystem;
|
||||
use crate::fzf;
|
||||
use crate::git;
|
||||
use git2::Repository;
|
||||
use std::error::Error;
|
||||
use std::fs;
|
||||
|
|
@ -8,15 +9,7 @@ use std::io::Write;
|
|||
use walkdir::WalkDir;
|
||||
|
||||
pub fn add(uri: String) -> Result<(), Box<dyn Error>> {
|
||||
let actual_uri = if uri.contains("://") || uri.contains('@') {
|
||||
uri
|
||||
} else {
|
||||
format!("https://github.com/{}", uri)
|
||||
};
|
||||
|
||||
let parts: Vec<&str> = actual_uri.split('/').collect();
|
||||
let user = parts[parts.len() - 2];
|
||||
let repo = parts[parts.len() - 1].replace(".git", "");
|
||||
let (actual_uri, user, repo) = git::meta(uri.as_str());
|
||||
|
||||
let cheat_path_str = filesystem::pathbuf_to_string(filesystem::cheat_pathbuf().unwrap());
|
||||
let tmp_path_str = format!("{}/tmp", cheat_path_str);
|
||||
|
|
|
|||
44
src/git.rs
Normal file
44
src/git.rs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
pub fn meta(uri: &str) -> (String, String, String) {
|
||||
let actual_uri = if uri.contains("://") {
|
||||
uri.to_string()
|
||||
} else if uri.contains('@') {
|
||||
uri.replace("git@", "https://").replace(':', "/")
|
||||
} else {
|
||||
format!("https://github.com/{}", uri)
|
||||
};
|
||||
|
||||
let parts: Vec<&str> = actual_uri.split('/').collect();
|
||||
let user = parts[parts.len() - 2];
|
||||
let repo = parts[parts.len() - 1].replace(".git", "");
|
||||
|
||||
(actual_uri.clone(), user.to_string(), repo)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_meta_github_https() {
|
||||
let (actual_uri, user, repo) = meta("https://github.com/denisidoro/navi");
|
||||
assert_eq!(actual_uri, "https://github.com/denisidoro/navi".to_string());
|
||||
assert_eq!(user, "denisidoro".to_string());
|
||||
assert_eq!(repo, "navi".to_string());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_meta_github_ssh() {
|
||||
let (actual_uri, user, repo) = meta("git@github.com:denisidoro/navi.git");
|
||||
assert_eq!(actual_uri, "https://github.com/denisidoro/navi".to_string());
|
||||
assert_eq!(user, "denisidoro".to_string());
|
||||
assert_eq!(repo.contains("navi"), true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_meta_gitlab_https() {
|
||||
let (actual_uri, user, repo) = meta("https://gitlab.com/user/repo.git");
|
||||
assert_eq!(actual_uri, "https://gitlab.com/user/repo.git".to_string());
|
||||
assert_eq!(user, "user".to_string());
|
||||
assert_eq!(repo.contains("repo"), true);
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,7 @@ mod handler;
|
|||
mod option;
|
||||
mod terminal;
|
||||
mod welcome;
|
||||
mod git;
|
||||
|
||||
use std::error::Error;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue