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};
|
use clap::{command, Parser, Subcommand};
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(name = "ya")]
|
#[command(name = "Ya", about, long_about = None)]
|
||||||
pub(super) struct Args {
|
pub(super) struct Args {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
pub(super) command: Option<Command>,
|
pub(super) command: Command,
|
||||||
|
|
||||||
/// Print version
|
/// Print version
|
||||||
#[arg(short = 'V', long)]
|
#[arg(short = 'V', long)]
|
||||||
pub version: bool,
|
pub(super) version: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
|
|
|
||||||
|
|
@ -1,44 +1,36 @@
|
||||||
mod args;
|
mod args;
|
||||||
|
|
||||||
use std::process;
|
|
||||||
|
|
||||||
use args::*;
|
use args::*;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> anyhow::Result<()> {
|
async fn main() -> anyhow::Result<()> {
|
||||||
let args = Args::parse();
|
if std::env::args_os().any(|s| s == "-V" || s == "--version") {
|
||||||
|
println!(
|
||||||
if args.version {
|
"Ya {} ({} {})",
|
||||||
println!("Ya {}", action_version());
|
env!("CARGO_PKG_VERSION"),
|
||||||
process::exit(0);
|
env!("VERGEN_GIT_SHA"),
|
||||||
|
env!("VERGEN_BUILD_DATE")
|
||||||
|
);
|
||||||
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
match &args.command.expect("No command provided") {
|
match Args::parse().command {
|
||||||
Command::Pub(cmd) => {
|
Command::Pub(cmd) => {
|
||||||
yazi_dds::init();
|
yazi_dds::init();
|
||||||
if let Err(e) = yazi_dds::Client::shot(&cmd.kind, cmd.receiver, None, &cmd.body()?).await {
|
if let Err(e) = yazi_dds::Client::shot(&cmd.kind, cmd.receiver, None, &cmd.body()?).await {
|
||||||
eprintln!("Cannot send message: {e}");
|
eprintln!("Cannot send message: {e}");
|
||||||
process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Command::PubStatic(cmd) => {
|
Command::PubStatic(cmd) => {
|
||||||
yazi_dds::init();
|
yazi_dds::init();
|
||||||
if let Err(e) = yazi_dds::Client::shot(&cmd.kind, 0, Some(cmd.severity), &cmd.body()?).await {
|
if let Err(e) = yazi_dds::Client::shot(&cmd.kind, 0, Some(cmd.severity), &cmd.body()?).await {
|
||||||
eprintln!("Cannot send message: {e}");
|
eprintln!("Cannot send message: {e}");
|
||||||
process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
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