mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
957bfddd3b
commit
749401108e
2 changed files with 14 additions and 22 deletions
|
|
@ -4,14 +4,14 @@ use anyhow::{bail, Result};
|
|||
use clap::{command, Parser, Subcommand};
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(name = "ya")]
|
||||
#[command(name = "Ya", about, long_about = None)]
|
||||
pub(super) struct Args {
|
||||
#[command(subcommand)]
|
||||
pub(super) command: Option<Command>,
|
||||
pub(super) command: Command,
|
||||
|
||||
/// Print version
|
||||
#[arg(short = 'V', long)]
|
||||
pub version: bool,
|
||||
pub(super) version: bool,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
|
|
|
|||
|
|
@ -1,44 +1,36 @@
|
|||
mod args;
|
||||
|
||||
use std::process;
|
||||
|
||||
use args::*;
|
||||
use clap::Parser;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
let args = Args::parse();
|
||||
|
||||
if args.version {
|
||||
println!("Ya {}", action_version());
|
||||
process::exit(0);
|
||||
if std::env::args_os().any(|s| s == "-V" || s == "--version") {
|
||||
println!(
|
||||
"Ya {} ({} {})",
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
env!("VERGEN_GIT_SHA"),
|
||||
env!("VERGEN_BUILD_DATE")
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
match &args.command.expect("No command provided") {
|
||||
match Args::parse().command {
|
||||
Command::Pub(cmd) => {
|
||||
yazi_dds::init();
|
||||
if let Err(e) = yazi_dds::Client::shot(&cmd.kind, cmd.receiver, None, &cmd.body()?).await {
|
||||
eprintln!("Cannot send message: {e}");
|
||||
process::exit(1);
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
Command::PubStatic(cmd) => {
|
||||
yazi_dds::init();
|
||||
if let Err(e) = yazi_dds::Client::shot(&cmd.kind, 0, Some(cmd.severity), &cmd.body()?).await {
|
||||
eprintln!("Cannot send message: {e}");
|
||||
process::exit(1);
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn action_version() -> String {
|
||||
format!(
|
||||
"{} ({} {})",
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
env!("VERGEN_GIT_SHA"),
|
||||
env!("VERGEN_BUILD_DATE")
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue