From 517ea96ffff379d23ac7e221784f3f09a95e4fcb Mon Sep 17 00:00:00 2001 From: Tony Date: Fri, 18 Oct 2024 11:16:02 +0800 Subject: [PATCH] Apply suggestions from code review --- src/config.rs | 12 ++++++------ src/verso.rs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/config.rs b/src/config.rs index 41aa49b..8805506 100644 --- a/src/config.rs +++ b/src/config.rs @@ -13,8 +13,8 @@ use servo_config::opts::{default_opts, set_options, Opts}; /// Command line arguments. #[derive(Clone, Debug, Default)] pub struct CliArgs { - /// Url to load initially. - pub initial_url: Option, + /// URL to load initially. + pub url: Option, } /// Configuration of Verso instance. @@ -25,14 +25,14 @@ pub struct Config { /// Path to resources directory. pub resource_dir: PathBuf, /// Command line arguments. - pub cli_args: CliArgs, + pub args: CliArgs, } fn parse_cli_args() -> Result { let args: Vec = std::env::args().collect(); let mut opts = getopts::Options::new(); - opts.optopt("", "initial-url", "load this url on start", "url"); + opts.optopt("", "url", "URL to load on start", "URL"); let matches = opts.parse(&args[1..])?; let initial_url = matches @@ -50,7 +50,7 @@ fn parse_cli_args() -> Result { } }); - Ok(CliArgs { initial_url }) + Ok(CliArgs { url: initial_url }) } impl Config { @@ -61,7 +61,7 @@ impl Config { Self { opts, resource_dir, - cli_args: parse_cli_args().unwrap_or_default(), + args: parse_cli_args().unwrap_or_default(), } } diff --git a/src/verso.rs b/src/verso.rs index fdafb75..1b78b6b 100644 --- a/src/verso.rs +++ b/src/verso.rs @@ -78,7 +78,7 @@ impl Verso { pub fn new(evl: &ActiveEventLoop, proxy: EventLoopProxy<()>, config: Config) -> Self { // Initialize configurations and Verso window let protocols = config.create_protocols(); - let initial_url = config.cli_args.initial_url.clone(); + let initial_url = config.args.url.clone(); config.init(); // Reserving a namespace to create TopLevelBrowsingContextId. PipelineNamespace::install(PipelineNamespaceId(0));