Skip to content

Commit 5dd987f

Browse files
committed
Update documentation.
1 parent bc2e36f commit 5dd987f

File tree

2 files changed

+69
-35
lines changed

2 files changed

+69
-35
lines changed

changelog.md

+16-29
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Changelog
2+
3+
## v2.0.1 (2021-08-15)
4+
5+
Update documentation. No functionality changes.
6+
17
## v2.0.0 (2021-07-25)
28

39
**Breaking**: Change result from `io::Result<ExitStatus>` to `io::Result<()>`.
@@ -7,22 +13,13 @@ issues with particular programs reporting success even on error, doing error han
713
close to impossible.
814
This releases alleviates most of the issues.
915

10-
Error information is gathered from the stderr channel of the process using a single read operation.
11-
This prevents the child process from keeping the main process alive if stderr is kept open.
12-
1316
## Notes
1417

1518
`wslview` always reports a 0 exit status, even if the path does not exist, which results in false positives.
16-
The stderr channel is written to but ignored in this implementation because of the successful exit status.
17-
Other programs write to stderr as part of normal operation. Firefox on Linux never seems to be able to load all
18-
the modules it wants to, so it writes to stderr but successfully opens. The only way to avoid these false positives
19-
is to special case wsl or for `wslview` to fix the unsuccessful exit status bug.
20-
This is only a minor problem and can mostly be ignored.
2119

22-
## v1.7.0 (2021-07-17)
20+
## v1.7.1 (2021-07-17)
2321

24-
* improved support [for
25-
windows-subsystem-for-linux](https://github.com/Byron/open-rs/pull/33#issue-691044025)
22+
* Improved support for [Windows Subsystem for Linux](https://github.com/Byron/open-rs/pull/33#issue-691044025)
2623

2724
## v1.7.0 (2021-04-18)
2825

@@ -63,37 +60,27 @@ YANKED to avoid potential for breakage by using 'explorer.exe' to open URLs.
6360
* **windows**: escape '&' in URLs. On windows, a shell is used to execute the command, which
6461
requires certain precautions for the URL to open to get through the interpreter.
6562

63+
## v1.1.1 (2016-04-10)
6664

67-
<a name="v1.1.1"></a>
68-
### v1.1.1 (2016-04-10)
69-
70-
71-
#### Bug Fixes
65+
### Bug Fixes
7266

7367
* **cargo:** no docs for open ([31605e0e](https://github.com/Byron/open-rs/commit/31605e0eddfb0cf8db635dd4d86131bc46beae78))
7468

75-
#### Improvements
69+
### Improvements
7670

7771
* **api:** allow OSStrings instead of &str ([1d13a671](https://github.com/Byron/open-rs/commit/1d13a671f2c9bd9616bf185fac77b32da1dcf8ee))
7872

79-
80-
81-
<a name="25c0e398"></a>
8273
## 25c0e398 (2015-07-08)
8374

84-
85-
#### Features
75+
### Features
8676

8777
* **open** added 'open' program ([a4c3a352](https://github.com/Byron/open-rs/commit/a4c3a352c8f912211d5ab48daaf41cb847ebcc0c))
8878

89-
#### Bug Fixes
79+
### Bug Fixes
9080

9181
* **cargo** description added ([0fcafb56](https://github.com/Byron/open-rs/commit/0fcafb56cdb5d154b3e983d17c93a1dd7c665426))
9282
* **open**
93-
* use result ([25c0e398](https://github.com/Byron/open-rs/commit/25c0e398856c24a2daf0444640567ed3fd2f4307))
94-
* don't use 'open' on linux ([30c96b1c](https://github.com/Byron/open-rs/commit/30c96b1cb95c1e03bede218b8fb03bbd9ada9317))
95-
* linux uses open before anything else ([4696d1a5](https://github.com/Byron/open-rs/commit/4696d1a5ec80691e97bb1be4261d4f79ee0ade4d))
83+
* use result ([25c0e398](https://github.com/Byron/open-rs/commit/25c0e398856c24a2daf0444640567ed3fd2f4307))
84+
* don't use 'open' on linux ([30c96b1c](https://github.com/Byron/open-rs/commit/30c96b1cb95c1e03bede218b8fb03bbd9ada9317))
85+
* linux uses open before anything else ([4696d1a5](https://github.com/Byron/open-rs/commit/4696d1a5ec80691e97bb1be4261d4f79ee0ade4d))
9686
* **rustup** (07560d233 2015-04-20) (built 2015-04-19) ([8b4e1558](https://github.com/Byron/open-rs/commit/8b4e1558f09937c555ab381ea6399a2c0758c23d))
97-
98-
99-

src/lib.rs

+53-6
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
//! ```
3131
3232
#[cfg(target_os = "windows")]
33-
pub use windows::{that, with};
33+
use windows as os;
3434

3535
#[cfg(target_os = "macos")]
36-
pub use macos::{that, with};
36+
use macos as os;
3737

3838
#[cfg(target_os = "ios")]
39-
pub use ios::{that, with};
39+
use ios as os;
4040

4141
#[cfg(any(
4242
target_os = "linux",
@@ -47,7 +47,7 @@ pub use ios::{that, with};
4747
target_os = "openbsd",
4848
target_os = "solaris"
4949
))]
50-
pub use unix::{that, with};
50+
use unix as os;
5151

5252
#[cfg(not(any(
5353
target_os = "linux",
@@ -72,13 +72,60 @@ use std::{
7272

7373
type Result = io::Result<()>;
7474

75-
/// Convenience function for opening the passed path in a new thread.
76-
/// See documentation of `that(...)` for more details.
75+
/// Open path with the default application.
76+
///
77+
/// # Examples
78+
///
79+
/// ```
80+
/// let path = "http://rust-lang.org";
81+
///
82+
/// match open::that(path) {
83+
/// Ok(()) => println!("Opened '{}' successfully.", path),
84+
/// Err(err) => panic!("An error occurred when opening '{}': {}", path, err),
85+
/// }
86+
/// ```
87+
///
88+
/// # Errors
89+
///
90+
/// A [`std::io::Error`] is returned on failure. Because different operating systems
91+
/// handle errors differently it is recommend to not match on a certain error.
92+
pub fn that<T: AsRef<OsStr> + Sized>(path: T) -> Result {
93+
os::that(path)
94+
}
95+
96+
/// Open path with the given application.
97+
///
98+
/// # Examples
99+
///
100+
/// ```
101+
/// let path = "http://rust-lang.org";
102+
/// let app = "firefox";
103+
///
104+
/// match open::with(path, app) {
105+
/// Ok(()) => println!("Opened '{}' successfully.", path),
106+
/// Err(err) => panic!("An error occurred when opening '{}': {}", path, err),
107+
/// }
108+
/// ```
109+
///
110+
/// # Errors
111+
///
112+
/// A [`std::io::Error`] is returned on failure. Because different operating systems
113+
/// handle errors differently it is recommend to not match on a certain error.
114+
pub fn with<T: AsRef<OsStr> + Sized>(path: T, app: impl Into<String>) -> Result {
115+
os::with(path, app)
116+
}
117+
118+
/// Open path with the default application in a new thread.
119+
///
120+
/// See documentation of [`that`] for more details.
77121
pub fn that_in_background<T: AsRef<OsStr> + Sized>(path: T) -> thread::JoinHandle<Result> {
78122
let path = path.as_ref().to_os_string();
79123
thread::spawn(|| that(path))
80124
}
81125

126+
/// Open path with the given application in a new thread.
127+
///
128+
/// See documentation of [`with`] for more details.
82129
pub fn with_in_background<T: AsRef<OsStr> + Sized>(
83130
path: T,
84131
app: impl Into<String>,

0 commit comments

Comments
 (0)