-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add a new
ya send
command to allow standalone client processe…
…s to communicate with DDS from the command line (#913)
- Loading branch information
Showing
26 changed files
with
349 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[package] | ||
name = "yazi-cli" | ||
version = "0.2.4" | ||
edition = "2021" | ||
license = "MIT" | ||
authors = [ "sxyazi <[email protected]>" ] | ||
description = "Yazi command-line interface" | ||
homepage = "https://yazi-rs.github.io" | ||
repository = "https://github.com/sxyazi/yazi" | ||
|
||
[dependencies] | ||
yazi-dds = { path = "../yazi-dds", version = "0.2.4" } | ||
|
||
# External dependencies | ||
anyhow = "1.0.82" | ||
clap = { version = "4.5.4", features = [ "derive" ] } | ||
tokio = { version = "1.37.0", features = [ "full" ] } | ||
|
||
[[bin]] | ||
name = "ya" | ||
path = "src/main.rs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use clap::{command, Parser, Subcommand}; | ||
|
||
#[derive(Parser)] | ||
#[command(name = "ya",version, about, long_about = None)] | ||
#[command(propagate_version = true)] | ||
pub(super) struct Args { | ||
#[command(subcommand)] | ||
pub(super) command: Command, | ||
} | ||
|
||
#[derive(Subcommand)] | ||
pub(super) enum Command { | ||
/// Send a message to remote instances. | ||
Send(CommandSend), | ||
} | ||
|
||
#[derive(clap::Args)] | ||
pub(super) struct CommandSend { | ||
pub(super) message: String, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
mod args; | ||
|
||
use args::*; | ||
use clap::Parser; | ||
|
||
#[tokio::main] | ||
async fn main() -> anyhow::Result<()> { | ||
let args = Args::parse(); | ||
|
||
match &args.command { | ||
Command::Send(cmd) => { | ||
yazi_dds::init(); | ||
if let Err(e) = yazi_dds::Client::shot(&cmd.message).await { | ||
eprintln!("Cannot send message: {e}"); | ||
std::process::exit(1); | ||
} | ||
} | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use mlua::{ExternalResult, IntoLua, Lua, Value}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::Body; | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct BodyBye {} | ||
|
||
impl BodyBye { | ||
#[inline] | ||
pub fn borrowed() -> Body<'static> { Self {}.into() } | ||
} | ||
|
||
impl<'a> From<BodyBye> for Body<'a> { | ||
fn from(value: BodyBye) -> Self { Self::Bye(value) } | ||
} | ||
|
||
impl IntoLua<'_> for BodyBye { | ||
fn into_lua(self, _: &Lua) -> mlua::Result<Value<'_>> { | ||
Err("BodyBye cannot be converted to Lua").into_lua_err() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.