summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Isidoro <denisidoro@users.noreply.github.com>2020-03-15 22:13:18 -0300
committerGitHub <noreply@github.com>2020-03-15 22:13:18 -0300
commit92cf10d10a3af002f65e1721062ba020a8c45824 (patch)
tree29f5c38f70c87b25cc1c24c49ebf45a4241eee0b
parent672fcc0c692ea19a3d6ea82f37c65cfd2eec544e (diff)
Allow repos with @ (#272)v2.1.1
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml2
-rw-r--r--src/cmds/best.rs6
-rw-r--r--src/cmds/repo.rs16
-rw-r--r--src/filesystem.rs8
5 files changed, 17 insertions, 17 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 911d087..fdef368 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -272,7 +272,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "navi"
-version = "2.1.0"
+version = "2.1.1"
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)",
diff --git a/Cargo.toml b/Cargo.toml
index ac29086..9e68323 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "navi"
-version = "2.1.0"
+version = "2.1.1"
authors = ["Denis Isidoro <denis_isidoro@live.com>"]
edition = "2018"
description = "An interactive cheatsheet tool for the command-line"
diff --git a/src/cmds/best.rs b/src/cmds/best.rs
index aa8bf58..ffce8fe 100644
--- a/src/cmds/best.rs
+++ b/src/cmds/best.rs
@@ -4,9 +4,9 @@ use crate::option::Config;
use std::error::Error;
pub fn main(query: String, args: Vec<String>, config: Config) -> Result<(), Box<dyn Error>> {
- if !args.is_empty() {
- cmds::aux::abort("passing arguments to 'navi best'", 201)
- } else {
+ if args.is_empty() {
cmds::core::main(Variant::Filter(query), config, false)
+ } else {
+ cmds::aux::abort("passing arguments to 'navi best'", 201)
}
}
diff --git a/src/cmds/repo.rs b/src/cmds/repo.rs
index a362661..a118fce 100644
--- a/src/cmds/repo.rs
+++ b/src/cmds/repo.rs
@@ -7,16 +7,8 @@ use std::fs;
use std::io::Write;
use walkdir::WalkDir;
-fn create_dir(path: &str) {
- fs::create_dir_all(path).unwrap_or(());
-}
-
-fn remove_dir(path: &str) {
- fs::remove_dir_all(path).unwrap_or(());
-}
-
pub fn add(uri: String) -> Result<(), Box<dyn Error>> {
- let actual_uri = if uri.contains("://") {
+ let actual_uri = if uri.contains("://") || uri.contains('@') {
uri
} else {
format!("https://github.com/{}", uri)
@@ -30,8 +22,8 @@ pub fn add(uri: String) -> Result<(), Box<dyn Error>> {
let tmp_path_str = format!("{}/tmp", cheat_path_str);
let tmp_path_str_with_trailing_slash = format!("{}/", &tmp_path_str);
- remove_dir(&tmp_path_str);
- create_dir(&tmp_path_str);
+ filesystem::remove_dir(&tmp_path_str);
+ filesystem::create_dir(&tmp_path_str);
eprintln!("Cloning {} into {}...\n", &actual_uri, &tmp_path_str);
@@ -76,7 +68,7 @@ pub fn add(uri: String) -> Result<(), Box<dyn Error>> {
fs::copy(from, to)?;
}
- remove_dir(&tmp_path_str);
+ filesystem::remove_dir(&tmp_path_str);
eprintln!("The following .cheat files were imported successfully:\n{}\n\nThey are now located at {}\n\nPlease run navi again to check the results.", files, cheat_path_str);
diff --git a/src/filesystem.rs b/src/filesystem.rs
index 4f97bdb..a6c7930 100644
--- a/src/filesystem.rs
+++ b/src/filesystem.rs
@@ -75,3 +75,11 @@ pub fn cheat_paths(config: &Config) -> String {
.clone()
.unwrap_or_else(cheat_paths_from_config_dir)
}
+
+pub fn create_dir(path: &str) {
+ fs::create_dir_all(path).unwrap_or(());
+}
+
+pub fn remove_dir(path: &str) {
+ fs::remove_dir_all(path).unwrap_or(());
+}