App-IODUtils
view release on metacpan or search on metacpan
script/get-iod-key view on Meta::CPAN
#!perl
use 5.010;
use strict;
use warnings;
use App::IODUtils;
use Perinci::CmdLine::Any;
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2024-06-24'; # DATE
our $DIST = 'App-IODUtils'; # DIST
our $VERSION = '0.164'; # VERSION
our %SPEC;
$SPEC{get_iod_key} = {
v => 1.1,
summary => 'Get key value from IOD configration file',
args => {
%App::IODUtils::common_args,
section => {
schema => 'str*',
req => 1,
pos => 1,
},
key => {
schema => 'str*',
req => 1,
pos => 2,
},
},
};
sub get_iod_key {
my %args = @_;
my $reader = App::IODUtils::_get_reader(\%args);
my $hoh = $reader->read_string($args{iod});
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_iod_key',
read_config => 0,
read_env => 0,
)->run;
# ABSTRACT: Get key value from IOD configration file
# PODNAME: get-iod-key
__END__
=pod
=encoding UTF-8
=head1 NAME
get-iod-key - Get key value from IOD configration file
=head1 VERSION
This document describes version 0.164 of get-iod-key (from Perl distribution App-IODUtils), released on 2024-06-24.
=head1 SYNOPSIS
Basic usage:
% get-iod-key /path/to/file.iod 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.198 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )