From 419f8eb672754cd99d6ec12a1f7af0d85ae70795 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 6 Feb 2014 22:19:20 +0000 Subject: trivial config module for dumping config We'll be using git config files after all... --- lib/PublicInbox/Config.pm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 lib/PublicInbox/Config.pm (limited to 'lib/PublicInbox/Config.pm') diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm new file mode 100644 index 00000000..4078585a --- /dev/null +++ b/lib/PublicInbox/Config.pm @@ -0,0 +1,18 @@ +# Copyright (C) 2014, Eric Wong and all contributors +# License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt) +package PublicInbox::Config; + +# returns key-value pairs of config directives in a hash +sub dump { + my ($class, $file) = @_; + + local $ENV{GIT_CONFIG} = $file; + + my @cfg = `git config -l`; + $? == 0 or die "git config -l failed: $?\n"; + chomp @cfg; + my %rv = map { split(/=/, $_, 2) } @cfg; + \%rv; +} + +1; -- cgit v1.2.3-24-ge0c7