Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(#197): --version, -v #198

Merged
merged 3 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions cli/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
use clap::{Parser, Subcommand};
use clap::{ArgAction, Parser, Subcommand};

// @todo #41:15min Add --report argument.
// Let's add --report option for generating reports in desired formats:
// We should support following formats: xml, tex, and txt. User should have
// ability to generate report in multiple formats as well: --report tex,xml,txt.
// @todo #79:25min Add --v option for verbose output.
// Let's add --v option for verbose output and debug logs. When this option is
// passed, we should show debug logs too.
#[derive(Parser, Debug)]
#[command(name = "fakehub")]
#[command(name = "fakehub", version = env!("CARGO_PKG_VERSION"))]
pub(crate) struct Args {
#[arg(short = 'v', action = ArgAction::Version)]
v: Option<bool>,
#[command(subcommand)]
pub(crate) command: Command,
}
Expand Down
19 changes: 19 additions & 0 deletions cli/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,25 @@ mod tests {
Ok(())
}

#[tag("deep")]
#[test]
fn outputs_version() -> Result<()> {
let assertion = Command::cargo_bin("fakehub")?.arg("--version").assert();
let bytes = assertion.get_output().stdout.as_slice();
let output = str::from_utf8(bytes)?;
assert!(output.contains(env!("CARGO_PKG_VERSION")));
Ok(())
}

#[test]
fn outputs_version_from_short() -> Result<()> {
let assertion = Command::cargo_bin("fakehub")?.arg("-v").assert();
let bytes = assertion.get_output().stdout.as_slice();
let output = str::from_utf8(bytes)?;
assert!(output.contains(env!("CARGO_PKG_VERSION")));
Ok(())
}

#[tag("deep")]
#[test]
fn outputs_start_opts() -> Result<()> {
Expand Down
Loading