mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat!: remove the meaningless --confirm option to simplify the shell command (#1982)
This commit is contained in:
parent
4bd8b0b446
commit
d3f572a8c7
4 changed files with 14 additions and 43 deletions
|
|
@ -28,28 +28,6 @@ pub fn init() -> anyhow::Result<()> {
|
||||||
try_init(false)?;
|
try_init(false)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove in v0.3.2
|
|
||||||
for c in &KEYMAP.manager {
|
|
||||||
for r in &c.run {
|
|
||||||
if r.name != "shell" {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if !r.bool("confirm") && !r.bool("interactive") {
|
|
||||||
let s = format!("`{}` ({})", c.on(), c.desc_or_run());
|
|
||||||
eprintln!(
|
|
||||||
r#"WARNING: In Yazi v0.3, the behavior of the interactive `shell` (i.e., shell templates) must be explicitly specified with either `--interactive` or `--confirm`.
|
|
||||||
|
|
||||||
Please replace e.g. `shell` with `shell --interactive`, `shell "my-template"` with `shell "my-template" --interactive`, in your keymap.toml for the key: {s}"#
|
|
||||||
);
|
|
||||||
return Ok(());
|
|
||||||
} else if r.bool("confirm") && r.bool("interactive") {
|
|
||||||
eprintln!(
|
|
||||||
"The `shell` command cannot specify both `--confirm` and `--interactive` at the same time.",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Remove in v0.3.6
|
// TODO: Remove in v0.3.6
|
||||||
if matches!(INPUT.create_title, popup::InputCreateTitle::One(_)) {
|
if matches!(INPUT.create_title, popup::InputCreateTitle::One(_)) {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ pub struct Opt {
|
||||||
run: Cow<'static, str>,
|
run: Cow<'static, str>,
|
||||||
block: bool,
|
block: bool,
|
||||||
orphan: bool,
|
orphan: bool,
|
||||||
confirm: bool,
|
|
||||||
interactive: bool,
|
interactive: bool,
|
||||||
cursor: Option<usize>,
|
cursor: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
@ -24,7 +23,6 @@ impl TryFrom<CmdCow> for Opt {
|
||||||
run: c.take_first_str().unwrap_or_default(),
|
run: c.take_first_str().unwrap_or_default(),
|
||||||
block: c.bool("block"),
|
block: c.bool("block"),
|
||||||
orphan: c.bool("orphan"),
|
orphan: c.bool("orphan"),
|
||||||
confirm: c.bool("confirm"),
|
|
||||||
interactive: c.bool("interactive"),
|
interactive: c.bool("interactive"),
|
||||||
cursor: c.get("cursor").and_then(Data::as_usize),
|
cursor: c.get("cursor").and_then(Data::as_usize),
|
||||||
};
|
};
|
||||||
|
|
@ -48,26 +46,9 @@ impl Tab {
|
||||||
Err(e) => return AppProxy::notify_warn("`shell` command", e),
|
Err(e) => return AppProxy::notify_warn("`shell` command", e),
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Remove in v0.3.2
|
|
||||||
if !opt.interactive && !opt.confirm {
|
|
||||||
AppProxy::notify_error(
|
|
||||||
"`shell` command",
|
|
||||||
r#"WARNING: In Yazi v0.3, the behavior of the interactive `shell` (i.e., shell templates) must be explicitly specified with either `--interactive` or `--confirm`.
|
|
||||||
|
|
||||||
Please replace e.g. `shell` with `shell --interactive`, `shell "my-template"` with `shell "my-template" --interactive`, in your keymap.toml"#,
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
} else if opt.interactive && opt.confirm {
|
|
||||||
AppProxy::notify_error(
|
|
||||||
"`shell` command",
|
|
||||||
"The `shell` command cannot specify both `--confirm` and `--interactive` at the same time.",
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let selected = self.hovered_and_selected(true).cloned().collect();
|
let selected = self.hovered_and_selected(true).cloned().collect();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
if !opt.confirm || opt.run.is_empty() {
|
if opt.interactive {
|
||||||
let mut result =
|
let mut result =
|
||||||
InputProxy::show(InputCfg::shell(opt.block).with_value(opt.run).with_cursor(opt.cursor));
|
InputProxy::show(InputCfg::shell(opt.block).with_value(opt.run).with_cursor(opt.cursor));
|
||||||
match result.recv().await {
|
match result.recv().await {
|
||||||
|
|
@ -75,6 +56,9 @@ Please replace e.g. `shell` with `shell --interactive`, `shell "my-template"` wi
|
||||||
_ => return,
|
_ => return,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if opt.run.is_empty() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
TasksProxy::open_with(
|
TasksProxy::open_with(
|
||||||
selected,
|
selected,
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,13 @@ impl Sendable {
|
||||||
Value::LightUserData(_) => Err("light userdata is not supported".into_lua_err())?,
|
Value::LightUserData(_) => Err("light userdata is not supported".into_lua_err())?,
|
||||||
Value::Integer(i) => Data::Integer(i),
|
Value::Integer(i) => Data::Integer(i),
|
||||||
Value::Number(n) => Data::Number(n),
|
Value::Number(n) => Data::Number(n),
|
||||||
Value::String(s) => Data::String(s.to_str()?.to_owned()),
|
Value::String(b) => {
|
||||||
|
if let Ok(s) = b.to_str() {
|
||||||
|
Data::String(s.to_owned())
|
||||||
|
} else {
|
||||||
|
Data::Bytes(b.as_bytes().to_owned())
|
||||||
|
}
|
||||||
|
}
|
||||||
Value::Table(t) => {
|
Value::Table(t) => {
|
||||||
let (mut i, mut map) = (1, HashMap::with_capacity(t.raw_len()));
|
let (mut i, mut map) = (1, HashMap::with_capacity(t.raw_len()));
|
||||||
for result in t.pairs::<Value, Value>() {
|
for result in t.pairs::<Value, Value>() {
|
||||||
|
|
@ -100,6 +106,7 @@ impl Sendable {
|
||||||
Value::Table(tbl)
|
Value::Table(tbl)
|
||||||
}
|
}
|
||||||
Data::Url(u) => Value::UserData(lua.create_any_userdata(u.clone())?),
|
Data::Url(u) => Value::UserData(lua.create_any_userdata(u.clone())?),
|
||||||
|
Data::Bytes(b) => Value::String(lua.create_string(b)?),
|
||||||
Data::Any(a) => {
|
Data::Any(a) => {
|
||||||
if let Some(t) = a.downcast_ref::<super::body::BodyYankIter>() {
|
if let Some(t) = a.downcast_ref::<super::body::BodyYankIter>() {
|
||||||
Value::UserData(lua.create_userdata(t.clone())?)
|
Value::UserData(lua.create_userdata(t.clone())?)
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ pub enum Data {
|
||||||
#[serde(skip_deserializing)]
|
#[serde(skip_deserializing)]
|
||||||
Url(Url),
|
Url(Url),
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
|
Bytes(Vec<u8>),
|
||||||
|
#[serde(skip)]
|
||||||
Any(Box<dyn Any + Send + Sync>),
|
Any(Box<dyn Any + Send + Sync>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue