summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqkzk <qu3nt1n@gmail.com>2023-10-27 22:07:40 +0200
committerqkzk <qu3nt1n@gmail.com>2023-10-27 22:07:40 +0200
commit840789072f0671cb5bf0456d7b2e1308f3383278 (patch)
tree5bc9d64d847e90fc27c25dd62a5e6472da21fe31
parentc2b1fe180dbde2b724d039861eeb3e8179eeb7c4 (diff)
removed some dependencies, little refactoring
-rw-r--r--Cargo.lock143
-rw-r--r--Cargo.toml3
-rw-r--r--development.md2
-rw-r--r--src/event_exec.rs31
-rw-r--r--src/opener.rs2
-rw-r--r--src/status.rs2
6 files changed, 38 insertions, 145 deletions
diff --git a/Cargo.lock b/Cargo.lock
index ee79ee8..f01590f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -216,12 +216,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
-name = "bitflags"
-version = "2.4.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
-
-[[package]]
name = "block"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -291,7 +285,7 @@ version = "0.15.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c76ee391b03d35510d9fa917357c7f1855bd9a6659c95a1b392e33f49b3369bc"
dependencies = [
- "bitflags 1.3.2",
+ "bitflags",
"cairo-sys-rs",
"glib",
"libc",
@@ -367,7 +361,7 @@ checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
dependencies = [
"ansi_term",
"atty",
- "bitflags 1.3.2",
+ "bitflags",
"strsim 0.8.0",
"textwrap",
"unicode-width",
@@ -780,33 +774,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
-name = "errno"
-version = "0.3.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860"
-dependencies = [
- "libc",
- "windows-sys 0.48.0",
-]
-
-[[package]]
-name = "fastrand"
-version = "2.0.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
-
-[[package]]
-name = "filedescriptor"
-version = "0.8.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7199d965852c3bac31f779ef99cbb4537f80e952e2d6aa0ffeb30cce00f4f46e"
-dependencies = [
- "libc",
- "thiserror",
- "winapi",
-]
-
-[[package]]
name = "filetime"
version = "0.2.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -840,8 +807,6 @@ dependencies = [
"copypasta",
"flate2",
"fs_extra",
- "futures 0.3.28",
- "gag",
"indicatif",
"lazy_static",
"log",
@@ -853,7 +818,7 @@ dependencies = [
"regex",
"rust-lzma",
"sanitize-filename",
- "serde_yaml 0.9.25",
+ "serde_yaml 0.9.27",
"shellexpand",
"skim-qkzk",
"strfmt",
@@ -868,7 +833,6 @@ dependencies = [
"unicode-segmentation",
"url-escape",
"users",
- "which",
"zip",
]
@@ -991,16 +955,6 @@ dependencies = [
]
[[package]]
-name = "gag"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a713bee13966e9fbffdf7193af71d54a6b35a0bb34997cd6c9519ebeb5005972"
-dependencies = [
- "filedescriptor",
- "tempfile",
-]
-
-[[package]]
name = "generic-array"
version = "0.14.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1054,7 +1008,7 @@ version = "0.15.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edb0306fbad0ab5428b0ca674a23893db909a98582969c9b537be4ced78c505d"
dependencies = [
- "bitflags 1.3.2",
+ "bitflags",
"futures-channel",
"futures-core",
"futures-executor",
@@ -1147,15 +1101,6 @@ dependencies = [
]
[[package]]
-name = "home"
-version = "0.5.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb"
-dependencies = [
- "windows-sys 0.48.0",
-]
-
-[[package]]
name = "humantime"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1319,12 +1264,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a"
[[package]]
-name = "linux-raw-sys"
-version = "0.4.10"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f"
-
-[[package]]
name = "lock_api"
version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1449,7 +1388,7 @@ version = "0.23.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c"
dependencies = [
- "bitflags 1.3.2",
+ "bitflags",
"cc",
"cfg-if",
"libc",
@@ -1462,7 +1401,7 @@ version = "0.24.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069"
dependencies = [
- "bitflags 1.3.2",
+ "bitflags",
"cfg-if",
"libc",
"memoffset 0.6.5",
@@ -1578,7 +1517,7 @@ version = "6.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c4b31c8722ad9171c6d77d3557db078cab2bd50afcc9d09c8b315c59df8ca4f"
dependencies = [
- "bitflags 1.3.2",
+ "bitflags",
"libc",
"once_cell",
"onig_sys",
@@ -1905,7 +1844,7 @@ version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
dependencies = [
- "bitflags 1.3.2",
+ "bitflags",
]
[[package]]
@@ -1914,7 +1853,7 @@ version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29"
dependencies = [
- "bitflags 1.3.2",
+ "bitflags",
]
[[package]]
@@ -1923,7 +1862,7 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
dependencies = [
- "bitflags 1.3.2",
+ "bitflags",
]
[[package]]
@@ -2018,19 +1957,6 @@ dependencies = [
]
[[package]]
-name = "rustix"
-version = "0.38.19"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "745ecfa778e66b2b63c88a61cb36e0eea109e803b0b86bf9879fbc77c70e86ed"
-dependencies = [
- "bitflags 2.4.1",
- "errno",
- "libc",
- "linux-raw-sys",
- "windows-sys 0.48.0",
-]
-
-[[package]]
name = "rustversion"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2096,9 +2022,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]]
name = "serde"
-version = "1.0.189"
+version = "1.0.190"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537"
+checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7"
dependencies = [
"serde_derive",
]
@@ -2115,9 +2041,9 @@ dependencies = [
[[package]]
name = "serde_derive"
-version = "1.0.189"
+version = "1.0.190"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5"
+checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3"
dependencies = [
"proc-macro2",
"quote",
@@ -2158,9 +2084,9 @@ dependencies = [
[[package]]
name = "serde_yaml"
-version = "0.9.25"
+version = "0.9.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1a49e178e4452f45cb61d0cd8cebc1b0fafd3e41929e996cef79aa3aca91f574"
+checksum = "3cc7a1570e38322cfe4154732e5110f887ea57e22b76f4bfd32b5bdd3368666c"
dependencies = [
"indexmap 2.0.2",
"itoa",
@@ -2238,7 +2164,7 @@ checksum = "ca4c3bcd3a72b5925fa30dae1e8ac51f8cf02f94c3dcb63e7f6136023c403374"
dependencies = [
"atty",
"beef",
- "bitflags 1.3.2",
+ "bitflags",
"chrono",
"clap 2.34.0",
"crossbeam",
@@ -2280,7 +2206,7 @@ version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "870427e30b8f2cbe64bf43ec4b86e88fe39b0a84b3f15efd9c9c2d020bc86eb9"
dependencies = [
- "bitflags 1.3.2",
+ "bitflags",
"dlib",
"lazy_static",
"log",
@@ -2451,7 +2377,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e02b4b303bf8d08bfeb0445cba5068a3d306b6baece1d5582171a9bf49188f91"
dependencies = [
"bincode",
- "bitflags 1.3.2",
+ "bitflags",
"flate2",
"fnv",
"once_cell",
@@ -2511,19 +2437,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14c39fd04924ca3a864207c66fc2cd7d22d7c016007f9ce846cbb9326331930a"
[[package]]
-name = "tempfile"
-version = "3.8.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef"
-dependencies = [
- "cfg-if",
- "fastrand",
- "redox_syscall 0.3.5",
- "rustix",
- "windows-sys 0.48.0",
-]
-
-[[package]]
name = "term"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2775,7 +2688,7 @@ version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e19c6ab038babee3d50c8c12ff8b910bdb2196f62278776422f50390d8e53d8"
dependencies = [
- "bitflags 1.3.2",
+ "bitflags",
"lazy_static",
"log",
"nix 0.24.3",
@@ -3006,7 +2919,7 @@ version = "0.29.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f3b068c05a039c9f755f881dc50f01732214f5685e379829759088967c46715"
dependencies = [
- "bitflags 1.3.2",
+ "bitflags",
"downcast-rs",
"libc",
"nix 0.24.3",
@@ -3045,7 +2958,7 @@ version = "0.29.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b950621f9354b322ee817a23474e479b34be96c2e909c14f7bc0100e9a970bc6"
dependencies = [
- "bitflags 1.3.2",
+ "bitflags",
"wayland-client",
"wayland-commons",
"wayland-scanner",
@@ -3074,18 +2987,6 @@ dependencies = [
]
[[package]]
-name = "which"
-version = "4.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
-dependencies = [
- "either",
- "home",
- "once_cell",
- "rustix",
-]
-
-[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index ae6f99d..26246ab 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -37,8 +37,6 @@ content_inspector = "0.2.4"
copypasta = "0.8.1"
flate2 = "1.0"
fs_extra = "1.2.0"
-futures = "0.3"
-gag = "1.0.0"
indicatif = { version = "0.17.1", features= ["in_memory"] }
lazy_static = "1.4.0"
log = { version = "0.4.0", features = ["std"] }
@@ -66,4 +64,3 @@ zip = "0.6.4"
tokio = "1"
ueberzug = "0.1.0"
unicode-segmentation = "1.10.1"
-which = "4.4.0"
diff --git a/development.md b/development.md
index 3481184..dc087cd 100644
--- a/development.md
+++ b/development.md
@@ -593,8 +593,8 @@ New view: Tree ! Toggle with 't', fold with 'z'. Navigate normally.
- [x] mtp mount with gio [nnn plugin](https://github.com/jarun/nnn/blob/master/plugins/mtpmount)
- [x] add MTP mount points to shortcuts
- [x] list, mount, unmount mtp mount points
+- [x] bulk, skim & removable are `None` until first use.
- [ ] remove dependencies
-- [ ] make every Navigable thing `None` until first use and then `Some(default)`
- [ ] document filepicking (from my config etc.).
- [ ] avoid multiple refreshs if we edit files ourself
diff --git a/src/event_exec.rs b/src/event_exec.rs
index 3bb6ba1..6950146 100644
--- a/src/event_exec.rs
+++ b/src/event_exec.rs
@@ -7,41 +7,33 @@ use std::str::FromStr;
use anyhow::{anyhow, Context, Result};
use log::info;
use sysinfo::SystemExt;
-use which::which;
use crate::action_map::ActionMap;
use crate::completion::InputCompleted;
use crate::config::Colors;
-use crate::constant_strings_paths::DIFF;
-use crate::constant_strings_paths::GIO;
-use crate::constant_strings_paths::MEDIAINFO;
-use crate::constant_strings_paths::NITROGEN;
-use crate::constant_strings_paths::SSHFS_EXECUTABLE;
-use crate::constant_strings_paths::{CONFIG_PATH, DEFAULT_DRAGNDROP};
+use crate::constant_strings_paths::{
+ CONFIG_PATH, DEFAULT_DRAGNDROP, DIFF, GIO, MEDIAINFO, NITROGEN, SSHFS_EXECUTABLE,
+};
use crate::cryptsetup::{lsblk_and_cryptsetup_installed, BlockDeviceAction};
use crate::fileinfo::FileKind;
use crate::filter::FilterKind;
-use crate::log::read_log;
-use crate::log::write_log_line;
-use crate::mocp::is_mocp_installed;
-use crate::mocp::Mocp;
+use crate::log::{read_log, write_log_line};
+use crate::mocp::{is_mocp_installed, Mocp};
use crate::mode::{InputSimple, MarkAction, Mode, Navigate, NeedConfirmation};
use crate::opener::{
execute_and_capture_output, execute_and_capture_output_without_check, execute_in_child,
execute_in_child_without_output_with_path,
};
use crate::password::{PasswordKind, PasswordUsage};
-use crate::preview::ExtensionKind;
-use crate::preview::Preview;
+use crate::preview::{ExtensionKind, Preview};
use crate::removable_devices::RemovableDevices;
use crate::selectable_content::SelectableContent;
use crate::shell_parser::ShellCommandParser;
use crate::status::Status;
use crate::tab::Tab;
-use crate::utils::is_program_in_path;
use crate::utils::{
- args_is_empty, disk_used_by_path, is_sudo_command, open_in_current_neovim, opt_mount_point,
- string_to_path,
+ args_is_empty, disk_used_by_path, is_program_in_path, is_sudo_command, open_in_current_neovim,
+ opt_mount_point, string_to_path,
};
/// Links events from tuikit to custom actions.
@@ -1314,6 +1306,9 @@ impl LeaveMode {
/// Execute a shell command typed by the user.
/// pipes and redirections aren't supported
/// but expansions are supported
+ /// Returns `Ok(true)` if a refresh is required,
+ /// `Ok(false)` if we should stay in the current mode (aka, a password is required)
+ /// It won't return an `Err` if the command fail.
pub fn shell(status: &mut Status) -> Result<bool> {
let shell_command = status.selected_non_mut().input.string();
let mut args = ShellCommandParser::new(&shell_command).compute(status)?;
@@ -1328,9 +1323,9 @@ impl LeaveMode {
status.ask_password(PasswordKind::SUDO, None, PasswordUsage::SUDOCOMMAND)?;
Ok(false)
} else {
- let Ok(executable) = which(executable) else {
+ if !is_program_in_path(&executable) {
return Ok(true);
- };
+ }
let current_directory = status
.selected_non_mut()
.directory_of_selected()?
diff --git a/src/opener.rs b/src/opener.rs
index f6d5760..1f36001 100644
--- a/src/opener.rs
+++ b/src/opener.rs
@@ -480,7 +480,7 @@ where
P: AsRef<Path>,
{
info!("execute_in_child_without_output_with_path. executable: {exe:?}, arguments: {args:?}");
- let params = if let Some(args) = args { args } else { &[] };
+ let params = args.unwrap_or(&[]);
Ok(Command::new(exe)
.stdin(Stdio::null())
.stdout(Stdio::null())
diff --git a/src/status.rs b/src/status.rs
index 7b43258..128a76c 100644
--- a/src/status.rs
+++ b/src/status.rs
@@ -199,7 +199,7 @@ impl Status {
pub fn execute_bulk(&self) -> Result<()> {
if let Some(bulk) = &self.bulk {
- bulk.execute_bulk(&self)?;
+ bulk.execute_bulk(self)?;
}
Ok(())
}