-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:
with_command()
to obtain the command that opens a program wit…
…h a given application.
- Loading branch information
Showing
6 changed files
with
36 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
use std::{ffi::OsStr, io, process::Command}; | ||
|
||
use crate::{CommandExt, IntoResult}; | ||
use std::{ffi::OsStr, process::Command}; | ||
|
||
pub fn commands<T: AsRef<OsStr>>(path: T) -> Vec<Command> { | ||
let mut cmd = Command::new("/bin/open"); | ||
cmd.arg(path.as_ref()); | ||
vec![cmd] | ||
} | ||
|
||
pub fn with<T: AsRef<OsStr>>(path: T, app: impl Into<String>) -> io::Result<()> { | ||
pub fn with_command<T: AsRef<OsStr>>(path: T, app: impl Into<String>) -> Command { | ||
let mut cmd = Command::new(app.into()); | ||
cmd.arg(path.as_ref()) | ||
.status_without_output() | ||
.into_result(&cmd) | ||
cmd.arg(path.as_ref()); | ||
cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,16 @@ | ||
use std::{ffi::OsStr, io, process::Command}; | ||
|
||
use crate::{CommandExt, IntoResult}; | ||
use std::{ffi::OsStr, process::Command}; | ||
|
||
pub fn commands<T: AsRef<OsStr>>(path: T) -> Vec<Command> { | ||
let mut cmd = Command::new("uiopen"); | ||
cmd.arg("--url").arg(path.as_ref()); | ||
vec![cmd] | ||
} | ||
|
||
pub fn with<T: AsRef<OsStr>>(path: T, app: impl Into<String>) -> io::Result<()> { | ||
pub fn with_command<T: AsRef<OsStr>>(path: T, app: impl Into<String>) -> Command { | ||
let mut cmd = Command::new("uiopen"); | ||
cmd.arg("--url") | ||
.arg(path.as_ref()) | ||
.arg("--bundleid") | ||
.arg(app.into()) | ||
.status_without_output() | ||
.into_result(&cmd) | ||
.arg(app.into()); | ||
cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,13 @@ | ||
use std::{ffi::OsStr, io, process::Command}; | ||
|
||
use crate::{CommandExt, IntoResult}; | ||
use std::{ffi::OsStr, process::Command}; | ||
|
||
pub fn commands<T: AsRef<OsStr>>(path: T) -> Vec<Command> { | ||
let mut cmd = Command::new("/usr/bin/open"); | ||
cmd.arg(path.as_ref()); | ||
vec![cmd] | ||
} | ||
|
||
pub fn with<T: AsRef<OsStr>>(path: T, app: impl Into<String>) -> io::Result<()> { | ||
pub fn with_command<T: AsRef<OsStr>>(path: T, app: impl Into<String>) -> Command { | ||
let mut cmd = Command::new("/usr/bin/open"); | ||
cmd.arg(path.as_ref()) | ||
.arg("-a") | ||
.arg(app.into()) | ||
.status_without_output() | ||
.into_result(&cmd) | ||
cmd.arg(path.as_ref()).arg("-a").arg(app.into()); | ||
cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,13 @@ | ||
use std::{ffi::OsStr, io, process::Command}; | ||
|
||
use crate::{CommandExt, IntoResult}; | ||
use std::{ffi::OsStr, process::Command}; | ||
|
||
pub fn commands<T: AsRef<OsStr>>(path: T) -> Vec<Command> { | ||
let mut cmd = Command::new("cmd"); | ||
cmd.arg("/c").arg("start").arg(path.as_ref()); | ||
vec![cmd] | ||
} | ||
|
||
pub fn with<T: AsRef<OsStr>>(path: T, app: impl Into<String>) -> io::Result<()> { | ||
pub fn with_command<T: AsRef<OsStr>>(path: T, app: impl Into<String>) -> Command { | ||
let mut cmd = Command::new("cmd"); | ||
cmd.arg("/c") | ||
.arg(app.into()) | ||
.arg(path.as_ref()) | ||
.status_without_output() | ||
.into_result(&cmd) | ||
cmd.arg("/c").arg(app.into()).arg(path.as_ref()); | ||
cmd | ||
} |