Skip to content

Commit

Permalink
fix: always persist static messages even when there are no remote cli…
Browse files Browse the repository at this point in the history
…ents (#928)
  • Loading branch information
sxyazi committed Apr 19, 2024
1 parent 09bc9aa commit ff14b9a
Show file tree
Hide file tree
Showing 52 changed files with 162 additions and 114 deletions.
6 changes: 2 additions & 4 deletions yazi-core/src/completion/commands/arrow.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use yazi_shared::{event::Cmd, render};
use yazi_shared::{event::{Cmd, Data}, render};

use crate::completion::Completion;

Expand All @@ -7,9 +7,7 @@ pub struct Opt {
}

impl From<Cmd> for Opt {
fn from(mut c: Cmd) -> Self {
Self { step: c.take_first_str().and_then(|s| s.parse().ok()).unwrap_or(0) }
}
fn from(c: Cmd) -> Self { Self { step: c.first().and_then(Data::as_isize).unwrap_or(0) } }
}

impl Completion {
Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/completion/commands/close.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct Opt {
}

impl From<Cmd> for Opt {
fn from(c: Cmd) -> Self { Self { submit: c.get_bool("submit") } }
fn from(c: Cmd) -> Self { Self { submit: c.bool("submit") } }
}

impl Completion {
Expand Down
4 changes: 2 additions & 2 deletions yazi-core/src/completion/commands/show.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{mem, ops::ControlFlow};

use yazi_shared::{event::Cmd, render};
use yazi_shared::{event::{Cmd, Data}, render};

use crate::completion::Completion;

Expand All @@ -19,7 +19,7 @@ impl From<Cmd> for Opt {
cache: c.take_any("cache").unwrap_or_default(),
cache_name: c.take_str("cache-name").unwrap_or_default(),
word: c.take_str("word").unwrap_or_default(),
ticket: c.take_str("ticket").and_then(|v| v.parse().ok()).unwrap_or(0),
ticket: c.get("ticket").and_then(Data::as_usize).unwrap_or(0),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions yazi-core/src/completion/commands/trigger.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{mem, path::{MAIN_SEPARATOR, MAIN_SEPARATOR_STR}};

use tokio::fs;
use yazi_shared::{emit, event::Cmd, render, Layer};
use yazi_shared::{emit, event::{Cmd, Data}, render, Layer};

use crate::completion::Completion;

Expand All @@ -20,7 +20,7 @@ impl From<Cmd> for Opt {
fn from(mut c: Cmd) -> Self {
Self {
word: c.take_first_str().unwrap_or_default(),
ticket: c.take_str("ticket").and_then(|s| s.parse().ok()).unwrap_or(0),
ticket: c.get("ticket").and_then(Data::as_usize).unwrap_or(0),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/folder/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub enum FilterCase {

impl From<&Cmd> for FilterCase {
fn from(c: &Cmd) -> Self {
match (c.get_bool("smart"), c.get_bool("insensitive")) {
match (c.bool("smart"), c.bool("insensitive")) {
(true, _) => Self::Smart,
(_, false) => Self::Sensitive,
(_, true) => Self::Insensitive,
Expand Down
6 changes: 2 additions & 4 deletions yazi-core/src/help/commands/arrow.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use yazi_shared::{event::Cmd, render};
use yazi_shared::{event::{Cmd, Data}, render};

use crate::help::Help;

Expand All @@ -7,9 +7,7 @@ pub struct Opt {
}

impl From<Cmd> for Opt {
fn from(mut c: Cmd) -> Self {
Self { step: c.take_first_str().and_then(|s| s.parse().ok()).unwrap_or(0) }
}
fn from(c: Cmd) -> Self { Self { step: c.first().and_then(Data::as_isize).unwrap_or(0) } }
}
impl From<isize> for Opt {
fn from(step: isize) -> Self { Self { step } }
Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/input/commands/backspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct Opt {
}

impl From<Cmd> for Opt {
fn from(c: Cmd) -> Self { Self { under: c.get_bool("under") } }
fn from(c: Cmd) -> Self { Self { under: c.bool("under") } }
}
impl From<bool> for Opt {
fn from(under: bool) -> Self { Self { under } }
Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/input/commands/close.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct Opt {
}

impl From<Cmd> for Opt {
fn from(c: Cmd) -> Self { Self { submit: c.get_bool("submit") } }
fn from(c: Cmd) -> Self { Self { submit: c.bool("submit") } }
}
impl From<bool> for Opt {
fn from(submit: bool) -> Self { Self { submit } }
Expand Down
4 changes: 2 additions & 2 deletions yazi-core/src/input/commands/complete.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::path::MAIN_SEPARATOR_STR;

use yazi_shared::{event::Cmd, render};
use yazi_shared::{event::{Cmd, Data}, render};

use crate::input::Input;

Expand All @@ -19,7 +19,7 @@ impl From<Cmd> for Opt {
fn from(mut c: Cmd) -> Self {
Self {
word: c.take_first_str().unwrap_or_default(),
ticket: c.take_str("ticket").and_then(|s| s.parse().ok()).unwrap_or(0),
ticket: c.get("ticket").and_then(Data::as_usize).unwrap_or(0),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/input/commands/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct Opt {
}

impl From<Cmd> for Opt {
fn from(c: Cmd) -> Self { Self { cut: c.get_bool("cut"), insert: c.get_bool("insert") } }
fn from(c: Cmd) -> Self { Self { cut: c.bool("cut"), insert: c.bool("insert") } }
}

impl Input {
Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/input/commands/forward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct Opt {
}

impl From<Cmd> for Opt {
fn from(c: Cmd) -> Self { Self { end_of_word: c.get_bool("end-of-word") } }
fn from(c: Cmd) -> Self { Self { end_of_word: c.bool("end-of-word") } }
}

impl Input {
Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/input/commands/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct Opt {
}

impl From<Cmd> for Opt {
fn from(c: Cmd) -> Self { Self { append: c.get_bool("append") } }
fn from(c: Cmd) -> Self { Self { append: c.bool("append") } }
}
impl From<bool> for Opt {
fn from(append: bool) -> Self { Self { append } }
Expand Down
8 changes: 4 additions & 4 deletions yazi-core/src/input/commands/move_.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use unicode_width::UnicodeWidthStr;
use yazi_shared::{event::Cmd, render};
use yazi_shared::{event::{Cmd, Data}, render};

use crate::input::{op::InputOp, snap::InputSnap, Input};

Expand All @@ -9,10 +9,10 @@ pub struct Opt {
}

impl From<Cmd> for Opt {
fn from(mut c: Cmd) -> Self {
fn from(c: Cmd) -> Self {
Self {
step: c.take_first_str().and_then(|s| s.parse().ok()).unwrap_or(0),
in_operating: c.get_bool("in-operating"),
step: c.first().and_then(Data::as_isize).unwrap_or(0),
in_operating: c.bool("in-operating"),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/input/commands/paste.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct Opt {
}

impl From<Cmd> for Opt {
fn from(c: Cmd) -> Self { Self { before: c.get_bool("before") } }
fn from(c: Cmd) -> Self { Self { before: c.bool("before") } }
}

impl Input {
Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/manager/commands/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct Opt {
}

impl From<Cmd> for Opt {
fn from(c: Cmd) -> Self { Self { force: c.get_bool("force") } }
fn from(c: Cmd) -> Self { Self { force: c.bool("force") } }
}

impl Manager {
Expand Down
4 changes: 2 additions & 2 deletions yazi-core/src/manager/commands/hover.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashSet;

use yazi_shared::{event::Cmd, fs::Url, render};
use yazi_shared::{event::{Cmd, Data}, fs::Url, render};

use crate::manager::Manager;

Expand All @@ -9,7 +9,7 @@ pub struct Opt {
}

impl From<Cmd> for Opt {
fn from(mut c: Cmd) -> Self { Self { url: c.take_first_str().map(Url::from) } }
fn from(mut c: Cmd) -> Self { Self { url: c.take_first().and_then(Data::into_url) } }
}
impl From<Option<Url>> for Opt {
fn from(url: Option<Url>) -> Self { Self { url } }
Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/manager/commands/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct Opt {
}

impl From<Cmd> for Opt {
fn from(c: Cmd) -> Self { Self { relative: c.get_bool("relative"), force: c.get_bool("force") } }
fn from(c: Cmd) -> Self { Self { relative: c.bool("relative"), force: c.bool("force") } }
}

impl Manager {
Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/manager/commands/open.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct Opt {

impl From<Cmd> for Opt {
fn from(c: Cmd) -> Self {
Self { interactive: c.get_bool("interactive"), hovered: c.get_bool("hovered") }
Self { interactive: c.bool("interactive"), hovered: c.bool("hovered") }
}
}

Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/manager/commands/paste.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct Opt {
}

impl From<Cmd> for Opt {
fn from(c: Cmd) -> Self { Self { force: c.get_bool("force"), follow: c.get_bool("follow") } }
fn from(c: Cmd) -> Self { Self { force: c.bool("force"), follow: c.bool("follow") } }
}

impl Manager {
Expand Down
10 changes: 5 additions & 5 deletions yazi-core/src/manager/commands/peek.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use yazi_shared::{event::Cmd, fs::Url, render};
use yazi_shared::{event::{Cmd, Data}, fs::Url, render};

use crate::manager::Manager;

Expand All @@ -13,10 +13,10 @@ pub struct Opt {
impl From<Cmd> for Opt {
fn from(mut c: Cmd) -> Self {
Self {
skip: c.take_first_str().and_then(|s| s.parse().ok()),
force: c.get_bool("force"),
only_if: c.take_str("only-if").map(Url::from),
upper_bound: c.get_bool("upper-bound"),
skip: c.first().and_then(Data::as_usize),
force: c.bool("force"),
only_if: c.take("only-if").and_then(Data::into_url),
upper_bound: c.bool("upper-bound"),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/manager/commands/quit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ impl From<()> for Opt {
fn from(_: ()) -> Self { Self::default() }
}
impl From<Cmd> for Opt {
fn from(c: Cmd) -> Self { Self { no_cwd_file: c.get_bool("no-cwd-file") } }
fn from(c: Cmd) -> Self { Self { no_cwd_file: c.bool("no-cwd-file") } }
}

impl Manager {
Expand Down
4 changes: 2 additions & 2 deletions yazi-core/src/manager/commands/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ pub struct Opt {
impl From<Cmd> for Opt {
fn from(mut c: Cmd) -> Self {
Self {
force: c.get_bool("force"),
permanently: c.get_bool("permanently"),
force: c.bool("force"),
permanently: c.bool("permanently"),
targets: c.take_any("targets").unwrap_or_default(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/manager/commands/rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct Opt {
impl From<Cmd> for Opt {
fn from(mut c: Cmd) -> Self {
Self {
force: c.get_bool("force"),
force: c.bool("force"),
empty: c.take_str("empty").unwrap_or_default(),
cursor: c.take_str("cursor").unwrap_or_default(),
}
Expand Down
6 changes: 2 additions & 4 deletions yazi-core/src/manager/commands/seek.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use yazi_config::PLUGIN;
use yazi_plugin::isolate;
use yazi_shared::{event::Cmd, render, MIME_DIR};
use yazi_shared::{event::{Cmd, Data}, render, MIME_DIR};

use crate::manager::Manager;

Expand All @@ -10,9 +10,7 @@ pub struct Opt {
}

impl From<Cmd> for Opt {
fn from(mut c: Cmd) -> Self {
Self { units: c.take_first_str().and_then(|s| s.parse().ok()).unwrap_or(0) }
}
fn from(c: Cmd) -> Self { Self { units: c.first().and_then(Data::as_i16).unwrap_or(0) } }
}

impl Manager {
Expand Down
6 changes: 2 additions & 4 deletions yazi-core/src/manager/commands/tab_close.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use yazi_shared::{event::Cmd, render};
use yazi_shared::{event::{Cmd, Data}, render};

use crate::manager::Tabs;

Expand All @@ -7,9 +7,7 @@ pub struct Opt {
}

impl From<Cmd> for Opt {
fn from(mut c: Cmd) -> Self {
Self { idx: c.take_first_str().and_then(|i| i.parse().ok()).unwrap_or(0) }
}
fn from(c: Cmd) -> Self { Self { idx: c.first().and_then(Data::as_usize).unwrap_or(0) } }
}

impl From<usize> for Opt {
Expand Down
6 changes: 3 additions & 3 deletions yazi-core/src/manager/commands/tab_create.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use yazi_boot::BOOT;
use yazi_proxy::AppProxy;
use yazi_shared::{event::Cmd, fs::Url, render};
use yazi_shared::{event::{Cmd, Data}, fs::Url, render};

use crate::{manager::Tabs, tab::Tab};

Expand All @@ -13,11 +13,11 @@ pub struct Opt {

impl From<Cmd> for Opt {
fn from(mut c: Cmd) -> Self {
if c.get_bool("current") {
if c.bool("current") {
Self { url: Default::default(), current: true }
} else {
Self {
url: c.take_first_str().map_or_else(|| Url::from(&BOOT.cwd), Url::from),
url: c.take_first().and_then(Data::into_url).unwrap_or_else(|| Url::from(&BOOT.cwd)),
current: false,
}
}
Expand Down
6 changes: 2 additions & 4 deletions yazi-core/src/manager/commands/tab_swap.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use yazi_shared::{event::Cmd, render};
use yazi_shared::{event::{Cmd, Data}, render};

use crate::manager::Tabs;

Expand All @@ -7,9 +7,7 @@ pub struct Opt {
}

impl From<Cmd> for Opt {
fn from(mut c: Cmd) -> Self {
Self { step: c.take_first_str().and_then(|s| s.parse().ok()).unwrap_or(0) }
}
fn from(c: Cmd) -> Self { Self { step: c.first().and_then(Data::as_isize).unwrap_or(0) } }
}

impl Tabs {
Expand Down
9 changes: 3 additions & 6 deletions yazi-core/src/manager/commands/tab_switch.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use yazi_shared::{event::Cmd, render};
use yazi_shared::{event::{Cmd, Data}, render};

use crate::manager::Tabs;

Expand All @@ -8,11 +8,8 @@ pub struct Opt {
}

impl From<Cmd> for Opt {
fn from(mut c: Cmd) -> Self {
Self {
step: c.take_first_str().and_then(|s| s.parse().ok()).unwrap_or(0),
relative: c.get_bool("relative"),
}
fn from(c: Cmd) -> Self {
Self { step: c.first().and_then(Data::as_isize).unwrap_or(0), relative: c.bool("relative") }
}
}

Expand Down
2 changes: 1 addition & 1 deletion yazi-core/src/manager/commands/update_mimetype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ impl TryFrom<Cmd> for Opt {
type Error = ();

fn try_from(mut c: Cmd) -> Result<Self, Self::Error> {
Ok(Self { updates: c.take_data("updates").ok_or(())?.into_table_string() })
Ok(Self { updates: c.take("updates").ok_or(())?.into_table_string() })
}
}

Expand Down
Loading

0 comments on commit ff14b9a

Please sign in to comment.