-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add integration tests as example projects (#37)
- Loading branch information
Showing
34 changed files
with
322 additions
and
6 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,4 +1,4 @@ | ||
/target | ||
target | ||
Cargo.lock | ||
.* | ||
|
||
|
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
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "example-basic" | ||
version = "0.0.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
fncmd = { path = "../.." } | ||
|
||
[dev-dependencies] | ||
trycmd = "0.14.16" | ||
|
||
[workspace] |
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
```console | ||
$ example-basic | ||
? 2 | ||
error: The following required arguments were not provided: | ||
<GREETING> | ||
|
||
USAGE: | ||
example-basic [OPTIONS] <GREETING> [NAME] | ||
|
||
For more information try --help | ||
|
||
``` | ||
|
||
```console | ||
$ example-basic --help | ||
example-basic 0.0.0 | ||
Prints greeting message | ||
|
||
USAGE: | ||
example-basic [OPTIONS] <GREETING> [NAME] | ||
|
||
ARGS: | ||
<GREETING> Greeting message | ||
<NAME> Name of someone to greet | ||
|
||
OPTIONS: | ||
--bang Whether to use “!” instead of “.” at the end of the message | ||
-h, --help Print help information | ||
-V, --version Print version information | ||
|
||
``` | ||
|
||
```console | ||
$ example-basic Hello World | ||
Hello, World. | ||
|
||
``` | ||
|
||
```console | ||
$ example-basic Hello --bang | ||
Hello! | ||
|
||
``` |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/// Prints greeting message. | ||
#[fncmd::fncmd] | ||
fn main( | ||
/// Greeting message. | ||
greeting: String, | ||
/// Name of someone to greet. | ||
name: Option<String>, | ||
/// Whether to use “!” instead of “.” at the end of the message. | ||
#[opt] | ||
bang: bool, | ||
) { | ||
if let Some(name) = name { | ||
println!("{greeting}, {name}{}", if bang { "!" } else { "." }); | ||
} else { | ||
println!("{greeting}{}", if bang { "!" } else { "." }); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#[test] | ||
fn trycmd() { trycmd::TestCases::new().case("README.md"); } |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "example-subcmds" | ||
version = "0.0.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
fncmd = { path = "../.." } | ||
|
||
[dev-dependencies] | ||
trycmd = "0.14.16" | ||
|
||
[workspace] |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
```console | ||
$ example-subcmds | ||
Top-level command is called. | ||
|
||
``` | ||
|
||
```console | ||
$ example-subcmds --help | ||
example-subcmds 0.0.0 | ||
|
||
USAGE: | ||
example-subcmds [SUBCOMMAND] | ||
|
||
OPTIONS: | ||
-h, --help Print help information | ||
-V, --version Print version information | ||
|
||
SUBCOMMANDS: | ||
child | ||
help Print this message or the help of the given subcommand(s) | ||
|
||
``` | ||
|
||
```console | ||
$ example-subcmds child | ||
One-level-deep subcommand is called. | ||
|
||
``` | ||
|
||
```console | ||
$ example-subcmds child grandchild | ||
Two-level-deep subcommand is called. | ||
|
||
``` | ||
|
||
```console | ||
$ example-subcmds orphan | ||
? 2 | ||
error: Found argument 'orphan' which wasn't expected, or isn't valid in this context | ||
|
||
USAGE: | ||
example-subcmds [SUBCOMMAND] | ||
|
||
For more information try --help | ||
|
||
``` | ||
|
||
```console | ||
$ example-subcmds-orphan | ||
Top-level orphan command is called. | ||
|
||
``` |
4 changes: 4 additions & 0 deletions
4
examples/example-subcmds/src/bin/example-subcmds-child-grandchild.rs
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#[fncmd::fncmd] | ||
pub fn main() { | ||
println!("Two-level-deep subcommand is called."); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#[fncmd::fncmd] | ||
pub fn main() { | ||
println!("One-level-deep subcommand is called."); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#[fncmd::fncmd] | ||
fn main() { | ||
println!("Top-level orphan command is called."); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#[fncmd::fncmd] | ||
fn main() { | ||
println!("Top-level command is called."); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#[test] | ||
fn trycmd() { trycmd::TestCases::new().case("README.md"); } |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "example-subcmdsflat" | ||
version = "0.0.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
fncmd = { path = "../.." } | ||
|
||
[dev-dependencies] | ||
trycmd = "0.14.16" | ||
|
||
[workspace] |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
```console | ||
$ example-subcmdsflat | ||
Top-level command is called. | ||
|
||
``` | ||
|
||
```console | ||
$ example-subcmdsflat --help | ||
example-subcmdsflat 0.0.0 | ||
|
||
USAGE: | ||
example-subcmdsflat [SUBCOMMAND] | ||
|
||
OPTIONS: | ||
-h, --help Print help information | ||
-V, --version Print version information | ||
|
||
SUBCOMMANDS: | ||
child | ||
help Print this message or the help of the given subcommand(s) | ||
|
||
``` | ||
|
||
```console | ||
$ example-subcmdsflat child | ||
One-level-deep subcommand is called. | ||
|
||
``` | ||
|
||
```console | ||
$ example-subcmdsflat child grandchild | ||
Two-level-deep subcommand is called. | ||
|
||
``` | ||
|
||
```console | ||
$ example-subcmdsflat orphan | ||
? 2 | ||
error: Found argument 'orphan' which wasn't expected, or isn't valid in this context | ||
|
||
USAGE: | ||
example-subcmdsflat [SUBCOMMAND] | ||
|
||
For more information try --help | ||
|
||
``` | ||
|
||
```console | ||
$ example-subcmdsflat-orphan | ||
Top-level orphan command is called. | ||
|
||
``` |
4 changes: 4 additions & 0 deletions
4
examples/example-subcmdsflat/src/bin/example-subcmdsflat-child-grandchild.rs
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#[fncmd::fncmd] | ||
pub fn main() { | ||
println!("Two-level-deep subcommand is called."); | ||
} |
4 changes: 4 additions & 0 deletions
4
examples/example-subcmdsflat/src/bin/example-subcmdsflat-child.rs
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#[fncmd::fncmd] | ||
pub fn main() { | ||
println!("One-level-deep subcommand is called."); | ||
} |
4 changes: 4 additions & 0 deletions
4
examples/example-subcmdsflat/src/bin/example-subcmdsflat-orphan.rs
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#[fncmd::fncmd] | ||
fn main() { | ||
println!("Top-level orphan command is called."); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#[fncmd::fncmd] | ||
fn main() { | ||
println!("Top-level command is called."); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#[test] | ||
fn trycmd() { trycmd::TestCases::new().case("README.md"); } |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[workspace] | ||
members = ["crates/*"] | ||
|
||
[workspace.package] | ||
version = "0.0.0" | ||
edition = "2021" |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "example-workspace-bar" | ||
version.workspace = true | ||
edition.workspace = true | ||
|
||
[dependencies] | ||
fncmd = { path = "../../../.." } | ||
|
||
[dev-dependencies] | ||
trycmd = "0.14.16" |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
```console | ||
$ example-workspace-bar | ||
Top-level command is called. | ||
|
||
``` | ||
|
||
```console | ||
$ example-workspace-bar child | ||
One-level-deep subcommand is called. | ||
|
||
``` |
4 changes: 4 additions & 0 deletions
4
examples/example-workspace/crates/bar/src/bin/example-workspace-bar-child.rs
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#[fncmd::fncmd] | ||
pub fn main() { | ||
println!("One-level-deep subcommand is called."); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#[fncmd::fncmd] | ||
fn main() { | ||
println!("Top-level command is called."); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#[test] | ||
fn trycmd() { trycmd::TestCases::new().case("README.md"); } |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "example-workspace-foo" | ||
version.workspace = true | ||
edition.workspace = true | ||
|
||
[dependencies] | ||
fncmd = { path = "../../../.." } | ||
|
||
[dev-dependencies] | ||
trycmd = "0.14.16" |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
```console | ||
$ example-workspace-foo | ||
Top-level command is called. | ||
|
||
``` | ||
|
||
```console | ||
$ example-workspace-foo child | ||
One-level-deep subcommand is called. | ||
|
||
``` |
4 changes: 4 additions & 0 deletions
4
examples/example-workspace/crates/foo/src/bin/example-workspace-foo-child.rs
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#[fncmd::fncmd] | ||
pub fn main() { | ||
println!("One-level-deep subcommand is called."); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#[fncmd::fncmd] | ||
fn main() { | ||
println!("Top-level command is called."); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#[test] | ||
fn trycmd() { trycmd::TestCases::new().case("README.md"); } |
Oops, something went wrong.