Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ pub struct Config {
pub(crate) url: String,
pub(crate) debug: i8,
pub(crate) token: String,
#[serde(default)]
pub(crate) default_agent: Option<String>,
}

impl Config {
Expand Down Expand Up @@ -38,6 +40,7 @@ impl Config {
url: "https://www.corgea.app".to_string(),
debug: 0,
token: "".to_string(),
default_agent: None,
};

let toml = toml::to_string(&config).expect("Failed to serialize config");
Expand Down Expand Up @@ -104,4 +107,19 @@ impl Config {

return self.debug;
}

pub fn set_default_agent(&mut self, agent: String) -> io::Result<()> {
self.default_agent = Some(agent);
self.save()
}

pub fn get_default_agent(&self) -> Option<String> {
if let Ok(agent) = env::var("CORGEA_DEFAULT_AGENT") {
if !agent.trim().is_empty() {
return Some(agent);
}
}

self.default_agent.clone()
}
}
Loading
Loading