Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions rust/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ rust_binary(
name = "selenium-manager",
srcs = ["src/main.rs"],
aliases = aliases(),
compile_data = ["//:license"],
edition = "2024",
# clap's `#[clap(about)]` derives the CLI description from
# CARGO_PKG_DESCRIPTION. Cargo sets this from Cargo.toml automatically, but
Expand Down
12 changes: 12 additions & 0 deletions rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ use std::path::Path;
use std::process::exit;
use std::sync::mpsc::Receiver;

const LICENSE: &str = include_str!("../../LICENSE");
const NOTICE: &str = include_str!("../../NOTICE");
Comment thread
qodo-code-review[bot] marked this conversation as resolved.
Resolved

/// Automated driver management for Selenium
#[derive(Parser, Debug)]
#[clap(version, about, long_about = None, help_template = "\
Expand Down Expand Up @@ -161,6 +164,10 @@ struct Cli {
#[clap(long)]
skip_browser_in_path: bool,

/// Print the license and copyright notices
#[clap(long)]
license: bool,

/// Add a skills file with Selenium best practices to the repository
#[clap(long, value_name = "FILE_NAME", num_args = 0..=1, default_missing_value = "")]
init_skills: Option<String>,
Expand All @@ -173,6 +180,11 @@ struct Cli {
fn main() {
let mut cli = Cli::parse();

if cli.license {
print!("{}\n{}", LICENSE, NOTICE);
return;
}

let debug = cli.debug || BooleanKey("debug", false).get_value();
let trace = cli.trace || BooleanKey("trace", false).get_value();
let log_level = StringKey(vec!["log-level"], &cli.log_level.unwrap_or_default()).get_value();
Expand Down
1 change: 1 addition & 0 deletions rust/tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ rust_test_suite(
size = "small",
srcs = glob(["**/*_tests.rs"]),
aliases = aliases(),
compile_data = ["//:license"],
data = [
"//rust:selenium-manager",
],
Expand Down
12 changes: 12 additions & 0 deletions rust/tests/output_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ use std::path::Path;

mod common;

const LICENSE: &str = include_str!("../../LICENSE");
const NOTICE: &str = include_str!("../../NOTICE");

#[test]
fn license_output_includes_license_and_notice() {
let mut cmd = get_selenium_manager();
cmd.arg("--license").assert().success().code(0);

let stdout = get_stdout(&mut cmd);
assert_eq!(stdout, format!("{}\n{}", LICENSE, NOTICE));
}

#[test]
fn json_output_test() {
let mut cmd = get_selenium_manager();
Expand Down
Loading