Skip to content

Commit

Permalink
src: cli, main: Add and use settings-file cli argument
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoantoniocardoso committed Jun 1, 2024
1 parent 614d734 commit 1d5ab66
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/cli/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ struct Args {
)]
mavlink: String,

/// Sets the settings file path
#[arg(
long,
value_name = "./settings.json",
default_value = "~/.config/mavlink-camera-manager/settings.json"
)]
settings_file: String,

/// Default settings to be used for different vehicles or environments.
#[arg(long, value_name = "NAME")]
default_settings: Option<custom::CustomEnvironment>,
Expand Down Expand Up @@ -147,6 +155,11 @@ pub fn log_path() -> String {
.expect("Clap arg \"log-path\" should always be \"Some(_)\" because of the default value.")
}

// Return the desired settings file
pub fn settings_file() -> String {
MANAGER.clap_matches.settings_file.clone()
}

// Return the desired address for the REST API
pub fn server_address() -> String {
MANAGER.clap_matches.rest_server.clone()
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async fn main() -> Result<(), std::io::Error> {
// Logger should start before everything else to register any log information
logger::manager::init();
// Settings should start before everybody else to ensure that the CLI are stored
settings::manager::init(None);
settings::manager::init(Some(&cli::manager::settings_file()));

mavlink::manager::Manager::init();

Expand Down

0 comments on commit 1d5ab66

Please sign in to comment.