package System::Introspector::Config;
use Moo;
use Config::General;

has config => (is => 'lazy');

has config_file => (is => 'ro', required => 1);

sub _build_config {
    my ($self) = @_;
    my $reader = Config::General->new($self->config_file);
    my %config = $reader->getall;
    return \%config;
}

sub groups { keys %{ $_[0]->config->{group} || {} } }

sub has_group { exists $_[0]->config->{group}{ $_[1] } }

sub config_for_group { $_[0]->config->{group}{ $_[1] } }

1;
