App-INIUtils
view release on metacpan or search on metacpan
script/get-ini-key view on Meta::CPAN
#!perl
use 5.010;
use strict;
use warnings;
use App::INIUtils;
use Perinci::CmdLine::Any;
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2024-06-24'; # DATE
our $DIST = 'App-INIUtils'; # DIST
our $VERSION = '0.035'; # VERSION
our %SPEC;
$SPEC{get_ini_key} = {
v => 1.1,
summary => 'Get key value from INI configration file',
args => {
%App::INIUtils::args_common,
section => {
schema => 'str*',
req => 1,
pos => 1,
},
key => {
schema => 'str*',
req => 1,
pos => 2,
},
},
};
sub get_ini_key {
my %args = @_;
my $reader = App::INIUtils::_get_ciir_reader(\%args);
my $hoh = $reader->read_string($args{ini});
my $section = $args{section};
my $key = $args{key};
return [404, "No such section"] unless exists $hoh->{$section};
return [404, "No such key"] unless exists $hoh->{$section}{$key};
[200, "OK", $hoh->{$section}{$key}];
}
Perinci::CmdLine::Any->new(
url => '/main/get_ini_key',
read_config => 0,
read_env => 0,
)->run;
# ABSTRACT: Get key value from INI configration file
# PODNAME: get-ini-key
__END__
=pod
=encoding UTF-8
=head1 NAME
get-ini-key - Get key value from INI configration file
=head1 VERSION
This document describes version 0.035 of get-ini-key (from Perl distribution App-INIUtils), released on 2024-06-24.
=head1 SYNOPSIS
Basic usage:
% get-ini-key /path/to/file.ini section key
=head1 OPTIONS
C<*> marks required options.
=head2 Main options
=over
=item B<--key>=I<s>*
(No description)
Can also be specified as the 3rd command-line argument.
=item B<--section>=I<s>*
(No description)
Can also be specified as the 2nd command-line argument.
=back
=head2 Output options
=over
( run in 2.287 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )