mirror of
https://github.com/lexmount/moli.git
synced 2026-10-03 00:00:44 +00:00
fix(cli): reject conflicting user agent flags
This commit is contained in:
+2
-2
@@ -470,10 +470,10 @@ pub struct CommonArgs {
|
||||
#[arg(long, num_args = 0..=1, default_missing_value = "")]
|
||||
pub log_filter_scopes: Option<String>,
|
||||
|
||||
#[arg(short = 'A', long)]
|
||||
#[arg(short = 'A', long, conflicts_with = "user_agent_suffix")]
|
||||
pub user_agent: Option<String>,
|
||||
|
||||
#[arg(long)]
|
||||
#[arg(long, conflicts_with = "user_agent")]
|
||||
pub user_agent_suffix: Option<String>,
|
||||
|
||||
/// Unencrypted PKCS#8 Ed25519 private key used for Web Bot Auth signatures.
|
||||
|
||||
+15
-2
@@ -674,8 +674,6 @@ fn app_config_uses_moli_user_agent_defaults() {
|
||||
"fetch",
|
||||
"--user-agent",
|
||||
"ExampleBrowser/1.0",
|
||||
"--user-agent-suffix",
|
||||
"ignored",
|
||||
"https://example.com",
|
||||
]))
|
||||
.unwrap();
|
||||
@@ -683,6 +681,21 @@ fn app_config_uses_moli_user_agent_defaults() {
|
||||
assert_eq!(config.browser.fetch().user_agent(), "ExampleBrowser/1.0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn user_agent_and_suffix_conflict() {
|
||||
let error = Cli::try_parse_from(normalize_args_for_compat([
|
||||
"moli",
|
||||
"fetch",
|
||||
"-A",
|
||||
"ExampleBrowser/1.0",
|
||||
"--user-agent-suffix",
|
||||
"internal-tester",
|
||||
"https://example.com",
|
||||
]))
|
||||
.unwrap_err();
|
||||
assert_eq!(error.kind(), clap::error::ErrorKind::ArgumentConflict);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn app_config_makes_fetch_quiet_unless_log_level_is_set() {
|
||||
let quiet_cli = Cli::try_parse_from(normalize_args_for_compat([
|
||||
|
||||
Reference in New Issue
Block a user