Skip to content

Commit 4b1f1b0

Browse files
committed
71: Improve the state of docs for new users r=killercup a=epage
2 parents c7d15f5 + 0ff900a commit 4b1f1b0

File tree

6 files changed

+87
-25
lines changed

6 files changed

+87
-25
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!--
2+
Hi! If you want to report a bug, request a feature, or ask a question on how to
3+
use assert_cli, you have come to the right place!
4+
5+
If you want to report a bug, please fill in the following. Otherwise, feel free
6+
to remove these lines.
7+
-->
8+
9+
- `assert_cli` version:
10+
- Rust version:
11+
- OS and version:

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!--
2+
Thank you for taking the time to contribute to this project!
3+
4+
To ease reviewing your changes and making sure we don't forget anything, please
5+
take a minute to check the following (remove lines that don't apply), and
6+
replace this text with a description of what this PR does. Bonus points for
7+
linking to issues! :)
8+
-->
9+
10+
- [ ] I have created tests for any new feature, or added regression tests for bugfixes.
11+
- [ ] `cargo test` succeeds
12+
- [ ] Clippy is happy: `cargo +nightly clippy` succeeds
13+
- [ ] Rustfmt is happy: `cargo +nightly fmt` succeeds

CONTRIBUTING.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Thanks for wanting to contribute!
2+
3+
Feel free to create issues or make pull requests, we'll try to quickly review them.
4+
5+
If you need to reach out to us, find a relevant [issue][Issues] or open a new one.
6+
7+
# Pull Requests
8+
9+
## Project Ideas
10+
11+
If you're looking for things to do check out the [open issues][Issues].
12+
Or take a grep through [all TODO comments][TODO] in the code and feel free to help us out there!
13+
14+
## Best Practices
15+
16+
We appreciate your help as-is. We'd love to help you through the process for contributing. We have some suggestions to help make things go more smoothly.
17+
18+
Before spending too much time on a PR, consider opening an issue so we can make sure we're aligned on how the problem should be solved.
19+
20+
# Releasing
21+
22+
When we're ready to release, a project owner should do the following
23+
- Determine what the next version is, according to semver
24+
- Update the version in `Cargo.toml` and in the `README.md` and commit
25+
- Run `git tag v<X>.<Y>.<Z>`
26+
- Push all of this to `master`
27+
- Create a github release
28+
- Identify what fixes, features, and breaking changes are in the release.
29+
- Run `cargo publish` (run `cargo login` first if needed)
30+
31+
[Issues]: https://github.com/killercup/assert_cli/issues
32+
[TODO]: https://github.com/killercup/assert_cli/search?q=TODO

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ homepage = "https://github.com/killercup/assert_cli"
99
documentation = "http://docs.rs/assert_cli/"
1010
readme = "README.md"
1111
categories = ["development-tools::testing"]
12-
keywords = ["cli", "testing", "assert"]
12+
keywords = ["cli", "testing", "assert", "command-line-interface"]
1313
build = "build.rs"
1414

1515
[[bin]]

README.md

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,48 @@
22

33
> **Test CLI Applications** - This crate checks the output of a child process is as expected.
44
5-
[![Build Status](https://travis-ci.org/killercup/assert_cli.svg)](https://travis-ci.org/killercup/assert_cli) [![Documentation](https://img.shields.io/badge/docs-master-blue.svg)][Documentation]
5+
[![Build Status](https://travis-ci.org/killercup/assert_cli.svg)][Travis]
6+
[![Documentation](https://img.shields.io/badge/docs-master-blue.svg)][Documentation]
7+
![License](https://img.shields.io/crates/l/assert_cli.svg)
8+
[![crates.io](https://img.shields.io/crates/v/assert_cli.svg)][Crates.io]
69

710
## Install
811

9-
Just add it to your `Cargo.toml`:
12+
For your tests, add it to your `Cargo.toml`:
1013

1114
```toml
12-
[dependencies]
15+
[dev-dependencies]
1316
assert_cli = "0.5"
1417
```
1518

1619
## Example
1720

1821
Here's a trivial example:
1922

20-
```rust
23+
```rust,ignore
2124
extern crate assert_cli;
2225
2326
fn main() {
24-
assert_cli::Assert::command(&["echo", "42"]).stdout().contains("42").unwrap();
25-
}
26-
```
27-
28-
Or if you'd rather use the macro, to save you some writing:
29-
30-
```rust
31-
#[macro_use] extern crate assert_cli;
32-
33-
fn main() {
34-
assert_cmd!(echo "42").stdout().contains("42").unwrap();
27+
assert_cli::Assert::main_binary().unwrap();
3528
}
3629
```
3730

38-
And here is one that will fail (which also shows `execute` which returns a
39-
`Result` and can be used instead of `unwrap`):
31+
And here is one that will fail (and demonstrates running arbitrary commands):
4032

4133
```rust
42-
#[macro_use] extern crate assert_cli;
34+
extern crate assert_cli;
4335

4436
fn main() {
45-
let test = assert_cmd!(ls "foo-bar-foo")
37+
assert_cli::Assert::command(&["ls", "foo-bar-foo"])
4638
.fails()
4739
.and()
4840
.stderr().contains("foo-bar-foo")
49-
.execute();
50-
assert!(test.is_ok());
41+
.unwrap();
5142
}
5243
```
5344

5445
If you want to match the program's output _exactly_, you can use
55-
`stdout().is`:
46+
`stdout().is` (and shows the macro form of `command`):
5647

5748
```rust,should_panic
5849
#[macro_use] extern crate assert_cli;
@@ -80,6 +71,13 @@ Assert Cli use [Environment][Environment] underneath to deal with environment va
8071

8172
More detailed information is available in the [documentation]. :-)
8273

74+
## Relevant crates
75+
76+
Other crates that might be useful in testing command line programs.
77+
* [dir-diff][dir-diff] for testing file side-effects.
78+
* [tempdir][tempdir] for scratchpad directories.
79+
* [duct][duct] for orchestrating multiple processes.
80+
8381
## License
8482

8583
Licensed under either of
@@ -96,5 +94,10 @@ submitted for inclusion in the work by you, as defined in the Apache-2.0
9694
license, shall be dual licensed as above, without any additional terms or
9795
conditions.
9896

97+
[Travis]: https://travis-ci.org/killercup/assert_cli
98+
[Crates.io]: https://crates.io/crates/assert_cli
9999
[Documentation]: https://docs.rs/assert_cli
100100
[Environment]: https://github.com/Freyskeyd/environment
101+
[dir-diff]: https://crates.io/crates/dir-diff
102+
[tempdir]: https://crates.io/crates/tempdir
103+
[duct]: https://crates.io/crates/duct

src/assert.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,10 @@ impl Assert {
176176
/// ```rust
177177
/// extern crate assert_cli;
178178
///
179-
/// assert_cli::Assert::command(&["echo", "42"])
180-
/// .stdout().contains("42")
179+
/// assert_cli::Assert::command(&["cat", "non-existing-file"])
180+
/// .fails()
181+
/// .and()
182+
/// .stderr().contains("non-existing-file")
181183
/// .unwrap();
182184
/// ```
183185
pub fn and(self) -> Self {
@@ -192,6 +194,7 @@ impl Assert {
192194
/// extern crate assert_cli;
193195
///
194196
/// assert_cli::Assert::command(&["echo", "42"])
197+
/// .succeeds()
195198
/// .unwrap();
196199
/// ```
197200
pub fn succeeds(mut self) -> Self {

0 commit comments

Comments
 (0)