diff --git a/src/args.rs b/src/args.rs index fe2ffb3..c7b00a4 100644 --- a/src/args.rs +++ b/src/args.rs @@ -237,7 +237,9 @@ pub struct Args { pub serve_path: PathBuf, #[serde(deserialize_with = "deserialize_bind_addrs")] #[serde(rename = "bind")] + #[serde(default = "default_addrs")] pub addrs: Vec, + #[serde(default = "default_port")] pub port: u16, #[serde(skip)] pub path_is_file: bool, @@ -273,8 +275,8 @@ impl Args { pub fn parse(matches: ArgMatches) -> Result { let mut args = Self { serve_path: default_serve_path(), - addrs: BindAddr::parse_addrs(&["0.0.0.0", "::"]).unwrap(), - port: 5000, + addrs: default_addrs(), + port: default_port(), ..Default::default() }; @@ -479,3 +481,11 @@ where fn default_serve_path() -> PathBuf { PathBuf::from(".") } + +fn default_addrs() -> Vec { + BindAddr::parse_addrs(&["0.0.0.0", "::"]).unwrap() +} + +fn default_port() -> u16 { + 5000 +}