mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 04:39:07 -04:00
feat(config): add ability to get value of variable
This commit is contained in:
parent
7bea406ab9
commit
f6b8cc7005
3 changed files with 43 additions and 56 deletions
|
@ -113,15 +113,24 @@ class Config {
|
|||
/// Map of key/value entries from config file.
|
||||
Map<String, dynamic> variables = {};
|
||||
|
||||
/// Sets the [value] of config [key]
|
||||
void setVariable(String key, dynamic value) {
|
||||
/// Returns the value of config [variable]
|
||||
String getValue(String variable) {
|
||||
try {
|
||||
return config.getValue(configPointer.value, variable);
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets the [value] of config [variable]
|
||||
void setValue(String variable, dynamic value) {
|
||||
try {
|
||||
if (value.runtimeType == bool) {
|
||||
config.setBool(configPointer.value, key, value);
|
||||
config.setBool(configPointer.value, variable, value);
|
||||
} else if (value.runtimeType == int) {
|
||||
config.setInt(configPointer.value, key, value);
|
||||
config.setInt(configPointer.value, variable, value);
|
||||
} else {
|
||||
config.setString(configPointer.value, key, value);
|
||||
config.setString(configPointer.value, variable, value);
|
||||
}
|
||||
variables = config.getVariables(configPointer.value);
|
||||
} catch (e) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue