mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 12:49:08 -04:00
refactor(config): simplify api methods names
This commit is contained in:
parent
9873d6ccc0
commit
da8494d3e2
5 changed files with 50 additions and 59 deletions
|
@ -222,7 +222,7 @@ Map<String, String> getEntries(Pointer<git_config> cfg) {
|
|||
/// (usually the local one).
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
void deleteEntry(Pointer<git_config> cfg, String variable) {
|
||||
void delete(Pointer<git_config> cfg, String variable) {
|
||||
final name = variable.toNativeUtf8().cast<Int8>();
|
||||
final error = libgit2.git_config_delete_entry(cfg, name);
|
||||
calloc.free(name);
|
||||
|
@ -236,7 +236,7 @@ void deleteEntry(Pointer<git_config> cfg, String variable) {
|
|||
///
|
||||
/// If regexp is present, then the iterator will only iterate over all
|
||||
/// values which match the pattern.
|
||||
List<String> getMultivarValue(
|
||||
List<String> multivarValues(
|
||||
Pointer<git_config> cfg,
|
||||
String variable,
|
||||
String? regexp,
|
||||
|
@ -270,7 +270,7 @@ List<String> getMultivarValue(
|
|||
/// highest level (usually the local one).
|
||||
///
|
||||
/// The regexp is applied case-sensitively on the value.
|
||||
void setMultivarValue(
|
||||
void setMultivar(
|
||||
Pointer<git_config> cfg,
|
||||
String variable,
|
||||
String regexp,
|
||||
|
|
|
@ -84,17 +84,14 @@ class Config {
|
|||
Config get snapshot => Config(bindings.snapshot(_configPointer));
|
||||
|
||||
/// Returns map of all the config variables and their values.
|
||||
Map<String, String> getEntries() {
|
||||
return bindings.getEntries(_configPointer);
|
||||
}
|
||||
Map<String, String> get variables => bindings.getEntries(_configPointer);
|
||||
|
||||
/// Returns the value of config [variable].
|
||||
String getValue(String variable) {
|
||||
return bindings.getValue(_configPointer, variable);
|
||||
}
|
||||
String operator [](String variable) =>
|
||||
bindings.getValue(_configPointer, variable);
|
||||
|
||||
/// Sets the [value] of config [variable].
|
||||
void setValue(String variable, dynamic value) {
|
||||
void operator []=(String variable, dynamic value) {
|
||||
if (value.runtimeType == bool) {
|
||||
bindings.setBool(_configPointer, variable, value);
|
||||
} else if (value.runtimeType == int) {
|
||||
|
@ -108,16 +105,14 @@ class Config {
|
|||
/// (usually the local one).
|
||||
///
|
||||
/// Throws a [LibGit2Error] if error occured.
|
||||
void deleteEntry(String variable) {
|
||||
bindings.deleteEntry(_configPointer, variable);
|
||||
}
|
||||
void delete(String variable) => bindings.delete(_configPointer, variable);
|
||||
|
||||
/// Returns list of values for multivar [variable]
|
||||
///
|
||||
/// If [regexp] is present, then the iterator will only iterate over all
|
||||
/// values which match the pattern.
|
||||
List<String> getMultivarValue(String variable, {String? regexp}) {
|
||||
return bindings.getMultivarValue(_configPointer, variable, regexp);
|
||||
List<String> multivar(String variable, {String? regexp}) {
|
||||
return bindings.multivarValues(_configPointer, variable, regexp);
|
||||
}
|
||||
|
||||
/// Sets the [value] of a multivar [variable] in the config file with the
|
||||
|
@ -125,8 +120,8 @@ class Config {
|
|||
///
|
||||
/// The [regexp] is applied case-sensitively on the value.
|
||||
/// Empty [regexp] sets [value] for all values of a multivar [variable].
|
||||
void setMultivarValue(String variable, String regexp, String value) {
|
||||
bindings.setMultivarValue(_configPointer, variable, regexp, value);
|
||||
void setMultivar(String variable, String regexp, String value) {
|
||||
bindings.setMultivar(_configPointer, variable, regexp, value);
|
||||
}
|
||||
|
||||
/// Deletes one or several values from a multivar [variable] in the config file
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue