Skip to content

Commit

Permalink
add cross-platform support
Browse files Browse the repository at this point in the history
  • Loading branch information
JettChenT committed Aug 30, 2022
1 parent bb14d91 commit ceed593
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "qali"
version = "0.3.5"
version = "0.3.6"
edition = "2021"
authors = ["[email protected]"]
license = "MIT/Apache-2.0"
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
```
Expand Down
26 changes: 16 additions & 10 deletions src/commands/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

Expand Down
1 change: 1 addition & 0 deletions src/db/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand Down

0 comments on commit ceed593

Please sign in to comment.