mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 04:39:07 -04:00
feat(config): update example
This commit is contained in:
parent
36f874c4a6
commit
f07fe88824
1 changed files with 10 additions and 2 deletions
|
@ -17,12 +17,20 @@ void main() {
|
||||||
try {
|
try {
|
||||||
final repoConfig = Config.open(path: '.git/config');
|
final repoConfig = Config.open(path: '.git/config');
|
||||||
|
|
||||||
print('All entries of repo config:');
|
print('\nAll entries of repo config:');
|
||||||
final entries = repoConfig.getEntries();
|
final entries = repoConfig.getEntries();
|
||||||
for (final entry in entries.entries) {
|
for (final entry in entries.entries) {
|
||||||
print('${entry.key}: ${entry.value}');
|
print('${entry.key}: ${entry.value}');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set value of config variable
|
||||||
|
repoConfig.setValue('core.variable', 'value');
|
||||||
|
print(
|
||||||
|
'\nNew value for variable "core.variable": ${repoConfig.getValue('core.variable')}');
|
||||||
|
|
||||||
|
// Delete variable
|
||||||
|
repoConfig.deleteEntry('core.variable');
|
||||||
|
|
||||||
repoConfig.close();
|
repoConfig.close();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
|
@ -33,7 +41,7 @@ void main() {
|
||||||
try {
|
try {
|
||||||
final globalConfig = Config.global();
|
final globalConfig = Config.global();
|
||||||
|
|
||||||
// get value of config variable
|
// Get value of config variable.
|
||||||
final userName = globalConfig.getValue('user.name');
|
final userName = globalConfig.getValue('user.name');
|
||||||
print('\nUser Name from global config: $userName');
|
print('\nUser Name from global config: $userName');
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue