fix: only warn about ignored flags when explicitly passed via CLI (#373)
The warning about launch-time options being ignored (when daemon is already running) was incorrectly shown when options were set via environment variables like AGENT_BROWSER_EXECUTABLE_PATH, even when no CLI flag was passed. Now the warning only appears when flags are explicitly passed on the command line, not when values come solely from environment variables. Fixes #372
This commit is contained in:
+39
-14
@@ -221,22 +221,51 @@ fn main() {
|
||||
}
|
||||
};
|
||||
|
||||
// Warn if launch-time options were specified but daemon was already running
|
||||
// Warn if launch-time options were explicitly passed via CLI but daemon was already running
|
||||
// Only warn about flags that were passed on the command line, not those set via environment
|
||||
// variables (since the daemon already uses the env vars when it starts).
|
||||
if daemon_result.already_running {
|
||||
let has_extensions = !flags.extensions.is_empty();
|
||||
let ignored_flags: Vec<&str> = [
|
||||
flags.executable_path.as_ref().map(|_| "--executable-path"),
|
||||
if has_extensions {
|
||||
if flags.cli_executable_path {
|
||||
Some("--executable-path")
|
||||
} else {
|
||||
None
|
||||
},
|
||||
if flags.cli_extensions {
|
||||
Some("--extension")
|
||||
} else {
|
||||
None
|
||||
},
|
||||
flags.profile.as_ref().map(|_| "--profile"),
|
||||
flags.state.as_ref().map(|_| "--state"),
|
||||
flags.args.as_ref().map(|_| "--args"),
|
||||
flags.user_agent.as_ref().map(|_| "--user-agent"),
|
||||
flags.proxy.as_ref().map(|_| "--proxy"),
|
||||
flags.proxy_bypass.as_ref().map(|_| "--proxy-bypass"),
|
||||
if flags.cli_profile {
|
||||
Some("--profile")
|
||||
} else {
|
||||
None
|
||||
},
|
||||
if flags.cli_state {
|
||||
Some("--state")
|
||||
} else {
|
||||
None
|
||||
},
|
||||
if flags.cli_args {
|
||||
Some("--args")
|
||||
} else {
|
||||
None
|
||||
},
|
||||
if flags.cli_user_agent {
|
||||
Some("--user-agent")
|
||||
} else {
|
||||
None
|
||||
},
|
||||
if flags.cli_proxy {
|
||||
Some("--proxy")
|
||||
} else {
|
||||
None
|
||||
},
|
||||
if flags.cli_proxy_bypass {
|
||||
Some("--proxy-bypass")
|
||||
} else {
|
||||
None
|
||||
},
|
||||
flags.ignore_https_errors.then(|| "--ignore-https-errors"),
|
||||
]
|
||||
.into_iter()
|
||||
@@ -250,10 +279,6 @@ fn main() {
|
||||
ignored_flags.join(", ")
|
||||
);
|
||||
}
|
||||
|
||||
if flags.ignore_https_errors {
|
||||
eprintln!("{} --ignore-https-errors ignored: daemon already running. Use 'agent-browser close' first to restart with this option.", color::warning_indicator());
|
||||
}
|
||||
}
|
||||
|
||||
// Validate mutually exclusive options
|
||||
|
||||
Reference in New Issue
Block a user