From ceed5934dec99738b05e095ebdca7ec463d743d3 Mon Sep 17 00:00:00 2001 From: JettChenT Date: Tue, 30 Aug 2022 10:12:25 +0800 Subject: [PATCH] add cross-platform support --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 13 +++++++++++-- src/commands/cmd.rs | 26 ++++++++++++++++---------- src/db/interface.rs | 1 + 5 files changed, 30 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6be8b81..bb49c3e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -363,7 +363,7 @@ dependencies = [ [[package]] name = "qali" -version = "0.3.5" +version = "0.3.6" dependencies = [ "anyhow", "clap", diff --git a/Cargo.toml b/Cargo.toml index 458f643..6c81ce0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "qali" -version = "0.3.5" +version = "0.3.6" edition = "2021" authors = ["contact@jettchen.me"] license = "MIT/Apache-2.0" diff --git a/README.md b/README.md index 00f95a9..b688c3f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ ![Crates.io](https://img.shields.io/crates/l/qali) ![Crates.io](https://img.shields.io/crates/v/qali) -Note: we're currently in the stage of initial development. [![asciicast](https://asciinema.org/a/517546.svg)](https://asciinema.org/a/517546) @@ -16,8 +15,18 @@ QALI can... - Reduce your mental workload ## Installation -Currently, a [Rust](https://www.rust-lang.org) installation is required +Note: QALI is not gauranteed to work in Windows. +### From source +download the [latest release](https://github.com/JettChenT/qali/releases/latest) of your platform, unzip, and move `q` and `qali` binaries to your `/usr/local/bin` folder + +### Homebrew +```shell +brew tap JettChenT/qali +brew intall qali +``` + +### Cargo ```shell cargo install qali ``` diff --git a/src/commands/cmd.rs b/src/commands/cmd.rs index a010bce..69468a7 100644 --- a/src/commands/cmd.rs +++ b/src/commands/cmd.rs @@ -11,16 +11,22 @@ pub struct Cmd { impl QaliCommand for Cmd { fn execute(&self, args: Option<&String>) -> anyhow::Result<()> { println!("$ {} {}", &self.command.blue(), args.unwrap_or(&"".to_string())); - let mut prefs = self.command.split_whitespace(); - let cmd = prefs.next().context("failed to get command")?; - let mut shell_cmd = Command::new(cmd); - for arg in prefs { - shell_cmd.arg(arg); - } - if let Some(arg) = args { - shell_cmd.arg(arg); - } - shell_cmd.status().context("Failed to execute process.")?; + let cmd = match args { + Some(args) => format!("{} {}", &self.command, args), + None => self.command.clone() + }; + if cfg!(target_os = "windows") { + Command::new("cmd") + .args(&["/C", cmd.as_str()]) + .status() + .context("Failed to execute process.") + } else { + Command::new("sh") + .arg("-c") + .arg(cmd.as_str()) + .status() + .context("Failed to execute process.") + }?; Ok(()) } diff --git a/src/db/interface.rs b/src/db/interface.rs index 2b136ab..73d6fef 100644 --- a/src/db/interface.rs +++ b/src/db/interface.rs @@ -46,6 +46,7 @@ pub fn ls() -> Result<()>{ .with(Modify::new(Columns::single(0)) .with(Format::new(|s| s.blue().to_string()))) .to_string(); + println!("Alias directory: {}\n", get_dir()?.to_string_lossy()); println!("{}", table); Ok(()) }