mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 10:45:30 +00:00
cli_helpers: run_with_cli_and_config: rename function and "f" argument
This commit is contained in:
parent
688372bdf2
commit
834a8c3fa2
2 changed files with 5 additions and 5 deletions
|
|
@ -7,7 +7,7 @@ static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
|
||||||
|
|
||||||
|
|
||||||
fn main(){
|
fn main(){
|
||||||
cli_helpers::run_with_cli_and_config::<aquatic::config::Config>(
|
cli_helpers::run_app_with_cli_and_config::<aquatic::config::Config>(
|
||||||
"aquatic: udp bittorrent tracker",
|
"aquatic: udp bittorrent tracker",
|
||||||
aquatic::run,
|
aquatic::run,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -36,10 +36,10 @@ fn default_config_as_toml<T>() -> String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn run_with_cli_and_config<T>(
|
pub fn run_app_with_cli_and_config<T>(
|
||||||
title: &str,
|
title: &str,
|
||||||
// Function that takes config file and runs application
|
// Function that takes config file and runs application
|
||||||
f: fn(T),
|
app_fn: fn(T),
|
||||||
) where T: Default + Serialize + DeserializeOwned {
|
) where T: Default + Serialize + DeserializeOwned {
|
||||||
let args: Vec<String> = ::std::env::args().collect();
|
let args: Vec<String> = ::std::env::args().collect();
|
||||||
|
|
||||||
|
|
@ -51,7 +51,7 @@ pub fn run_with_cli_and_config<T>(
|
||||||
print!("{}", default_config_as_toml::<T>());
|
print!("{}", default_config_as_toml::<T>());
|
||||||
} else if let Some(config_file) = opts.config_file {
|
} else if let Some(config_file) = opts.config_file {
|
||||||
match config_from_toml_file(config_file){
|
match config_from_toml_file(config_file){
|
||||||
Ok(config) => f(config),
|
Ok(config) => app_fn(config),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("Error while reading config file: {}", err);
|
eprintln!("Error while reading config file: {}", err);
|
||||||
|
|
||||||
|
|
@ -59,7 +59,7 @@ pub fn run_with_cli_and_config<T>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
f(T::default())
|
app_fn(T::default())
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue