From 85b463b9b832e16f93d71bcd551d86a3ae226015 Mon Sep 17 00:00:00 2001 From: Valerie Date: Fri, 18 Jun 2021 11:30:14 -0400 Subject: [PATCH 1/3] added exit codes --- src/main.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index b93ffc8..bd68778 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ use std::{ env::{args, current_dir}, path::Path, - process::{Command, Stdio} + process::{Command, exit, Stdio} }; mod config; @@ -20,8 +20,8 @@ fn main() { let i_target = arg_target.unwrap_or(&default); let target = Path::new(i_target); if !target.exists() { - println!("\"{}\" does not exist.", i_target); - return; + println!("open: \"{}\" does not exist.", i_target); + exit(1); } let i_ext = target.extension(); let i_filename: String; @@ -43,11 +43,11 @@ fn main() { let i_exe = config.get(ext, "command"); if i_exe.is_none() { match ext { - "open" => {}, - "dir" => println!("No command specified for directories."), - _ => println!("No command specified for \"{}\" files.", ext) + "open" => println!("open: no zero-parameter command specified."), + "dir" => println!("open: no command specified for directories."), + _ => println!("open: no command specified for \"{}\" files.", ext) } - return; + exit(1); } let exe = i_exe.unwrap(); let mut parts = exe.split(" "); From cb5fb6b1ac1bedb97fe5ebc6c19b93556650c9fe Mon Sep 17 00:00:00 2001 From: Valerie Date: Wed, 23 Jun 2021 16:33:25 -0400 Subject: [PATCH 2/3] added README --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..71c4db8 --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +# open + +This is a Rust rewrite of my `open` script from my shell scripts. It's written to be faster and more customizable; it now features "local" configs and a zero-operand command, allowing the user to specify how files should be opened differently, and for opening a project, etc. + +For example, for + +```ini +[open] +# zero-operand command +command = atom . + +[.md] +command = typora + +[.rs] +command = atom + +[filename:.gitignore] +command = vim +shell = true +``` + +I can use `open` to open the directory in Atom, or I could use `open src/main.rs` to open `main.rs` in Atom, and I can specify these on a per-project basis. + +For directories with a local config, any missing values will be filled in by the global config (`~/.config/open.conf`), which means local configs can be shorter. + From 357fac445fb99775d7af4b39b4f8e394a2564330 Mon Sep 17 00:00:00 2001 From: Valerie Date: Sun, 4 Jul 2021 14:27:16 -0400 Subject: [PATCH 3/3] updated README --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 71c4db8..0e8b470 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # open -This is a Rust rewrite of my `open` script from my shell scripts. It's written to be faster and more customizable; it now features "local" configs and a zero-operand command, allowing the user to specify how files should be opened differently, and for opening a project, etc. +A Rust implementation of MacOS's `open` command (`xdg-open`). It's written to be quickly and easily customizable, features separate local and global configs, and a zero-operand command allowing the user to specify how files should be opened differently, and for opening a project, etc. For example, for @@ -23,4 +23,3 @@ shell = true I can use `open` to open the directory in Atom, or I could use `open src/main.rs` to open `main.rs` in Atom, and I can specify these on a per-project basis. For directories with a local config, any missing values will be filled in by the global config (`~/.config/open.conf`), which means local configs can be shorter. -