Commit 8fe62da8 authored by Ian Jackson's avatar Ian Jackson
Browse files

Move default_config_file() into arti-client

This will let other embedders use it.
parent c76c79d0
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ use std::collections::HashMap;
use std::path::Path;
use std::path::PathBuf;
use std::time::Duration;
pub use tor_config::{CfgPath, ConfigBuildError, Reconfigure};
pub use tor_config::{CfgPath, CfgPathError, ConfigBuildError, Reconfigure};

/// Types for configuring how Tor circuits are built.
pub mod circ {
@@ -370,6 +370,11 @@ pub(crate) fn default_fs_mistrust() -> fs_mistrust::Mistrust {
    mistrust
}

/// Return a filename for the default user configuration file.
pub fn default_config_file() -> Result<PathBuf, CfgPathError> {
    CfgPath::new("${ARTI_CONFIG}/arti.toml".into()).path()
}

#[cfg(test)]
mod test {
    #![allow(clippy::unwrap_used)]
+1 −6
Original line number Diff line number Diff line
@@ -52,7 +52,6 @@ mod options;

pub use cmdline::CmdLine;
pub use options::ARTI_DEFAULTS;
use tor_config::{CfgPath, CfgPathError};

/// The synchronous configuration builder type we use.
///
@@ -207,15 +206,11 @@ where
    builder
}

/// Return a filename for the default user configuration file.
pub fn default_config_file() -> Result<PathBuf, CfgPathError> {
    CfgPath::new("${ARTI_CONFIG}/arti.toml".into()).path()
}

#[cfg(test)]
mod test {
    #![allow(clippy::unwrap_used)]
    use super::*;
    use arti_client::config::default_config_file;
    use tempfile::tempdir;

    static EX_TOML: &str = "
+2 −2
Original line number Diff line number Diff line
@@ -128,8 +128,8 @@ pub use cfg::{
};
pub use logging::{LoggingConfig, LoggingConfigBuilder};

use arti_client::config::default_config_file;
use arti_client::{TorClient, TorClientConfig};
use arti_config::default_config_file;
use safelog::with_safe_logging_suppressed;
use tor_rtcompat::{BlockOn, Runtime};

@@ -263,7 +263,7 @@ pub fn main_main() -> Result<()> {
    // correct behavior is different depending on whether the filename is given
    // explicitly or not.
    let mut config_file_help = "Specify which config file(s) to read.".to_string();
    if let Ok(default) = arti_config::default_config_file() {
    if let Ok(default) = default_config_file() {
        // If we couldn't resolve the default config file, then too bad.  If something
        // actually tries to use it, it will produce an error, but don't fail here
        // just for that reason.