From 53fe671bffae9c63117cd4bdab9814ac489ef8ca Mon Sep 17 00:00:00 2001 From: Aleksey Kulikov Date: Thu, 3 Jun 2021 17:20:36 +0300 Subject: [PATCH] feat: update config example --- example/config_example.dart | 54 ++++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 9 deletions(-) diff --git a/example/config_example.dart b/example/config_example.dart index 2502764..9c62342 100644 --- a/example/config_example.dart +++ b/example/config_example.dart @@ -3,15 +3,51 @@ import 'package:libgit2dart/libgit2dart.dart'; void main() { final repoConfig = Config(path: '.git/config'); - final isBare = repoConfig.getBool('core.bare'); - final isLoggingAllRefUpdates = repoConfig.getBool('core.logallrefupdates'); - final repoFormatVersion = repoConfig.getInt('core.repositoryformatversion'); - final remoteOriginUrl = repoConfig.getString('remote.origin.url'); - - print('Repository is bare = $isBare'); - print('Logging all ref updates = $isLoggingAllRefUpdates'); - print('Repository format version = $repoFormatVersion'); - print('Remote origin url = $remoteOriginUrl'); + print('All entries of repo config:'); + for (final entry in repoConfig.entries.entries) { + print('${entry.key}: ${entry.value}'); + } repoConfig.close(); + + try { + final systemConfig = Config.system(); + + print( + '\nUser Name from system config: ${systemConfig.entries['user.name']}'); + + systemConfig.close(); + } catch (e) { + print('\n$e'); + } + + try { + final globalConfig = Config.global(); + + print( + '\nUser Name from global config: ${globalConfig.entries['user.name']}'); + + globalConfig.close(); + } catch (e) { + print('\n$e'); + } + + try { + final xdgConfig = Config.xdg(); + print('\nAll entries of repo config:'); + + print('\nUser Name from xdg config: ${xdgConfig.entries['user.name']}'); + + xdgConfig.close(); + } catch (e) { + print('\n$e'); + } + + final config = Config(); + + print('\nAll entries of system/global config:'); + for (final entry in config.entries.entries) { + print('${entry.key}: ${entry.value}'); + } + config.close(); }