Skip to content

Commit

Permalink
Merge pull request #2 from SpiralOutDotEu/feature/version-command
Browse files Browse the repository at this point in the history
feat(cli): ✨ Add --version and --v commands
  • Loading branch information
SpiralOutDotEu authored Oct 28, 2023
2 parents bce9e5a + ae42c86 commit a22abd7
Show file tree
Hide file tree
Showing 5 changed files with 275 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"conventionalCommits.scopes": [
"ci"
"ci",
"cli"
]
}
244 changes: 244 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[dev-dependencies]
assert_cmd = "2.0.12"
predicates = "3.0.4"
7 changes: 6 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
use std::env;

fn main() {
println!("Hello, world!");
let args: Vec<String> = env::args().collect();
if args.contains(&"--version".to_string()) || args.contains(&"--v".to_string()) {
println!("Zero Knowledge Whitelist Tool, version {}", env!("CARGO_PKG_VERSION"));
}
}
19 changes: 19 additions & 0 deletions tests/version_command_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#[cfg(test)]
mod tests {
// use super::*;
use assert_cmd::Command;

#[test]
fn test_version_command() {
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap();
cmd.arg("--version")
.assert()
.success()
.stdout(predicates::str::contains(env!("CARGO_PKG_VERSION")));

cmd.arg("--v")
.assert()
.success()
.stdout(predicates::str::contains(env!("CARGO_PKG_VERSION")));
}
}

0 comments on commit a22abd7

Please sign in to comment.