-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e799d67
commit de6ab40
Showing
24 changed files
with
260 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,33 @@ | ||
//SPDXFileCopyrightText: 2024 Ryuichi Ueda [email protected] | ||
//SPDXLicense-Identifier: BSD-3-Clause | ||
|
||
use crate::error::exec::ExecError; | ||
use std::collections::HashMap; | ||
use std::env; | ||
|
||
#[derive(Debug, Default)] | ||
pub struct Data { | ||
pub flags: String, | ||
pub parameters: HashMap<String, String>, | ||
} | ||
|
||
impl Data { | ||
pub fn get_param(&mut self, key: &str) -> String { | ||
if ! self.parameters.contains_key(key) { | ||
if let Ok(val) = env::var(key) { | ||
self.set_param(key, &val); | ||
pub fn get_param(&mut self, name: &str) -> Result<String, ExecError> { | ||
if ! self.parameters.contains_key(name) { | ||
if let Ok(val) = env::var(name) { | ||
self.set_param(name, &val)?; | ||
} | ||
} | ||
|
||
match self.parameters.get(key) { | ||
let ans = match self.parameters.get(name) { | ||
Some(val) => val, | ||
None => "", | ||
}.to_string() | ||
}.to_string(); | ||
|
||
Ok(ans) | ||
} | ||
|
||
pub fn set_param(&mut self, key: &str, val: &str) { | ||
self.parameters.insert(key.to_string(), val.to_string()); | ||
pub fn set_param(&mut self, name: &str, val: &str) -> Result<(), ExecError> { | ||
self.parameters.insert(name.to_string(), val.to_string()); | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.