App-hr
view release on metacpan or search on metacpan
$data_linepos++;
last if $pos >= $data_pos;
}
seek DATA, $data_pos, 0;
\%toc;
};
if ($toc->{$_[1]}) {
warn "[datapacker] $_[1] FOUND in packed modules\n" if $debug;
seek DATA, $toc->{$_[1]}[0], 0;
read DATA, my($content), $toc->{$_[1]}[1];
my ($order, $lineoffset) = split(';', $toc->{$_[1]}[2]);
$content =~ s/^#//gm;
$content = "# line ".($data_linepos + $order+1 + $lineoffset)." \"".__FILE__."\"\n" . $content;
open my $fh, '<', \$content
or die "DataPacker error loading $_[1]: $!";
return $fh;
} else {
warn "[datapacker] $_[1] NOT found in packed modules\n" if $debug;
}
return;
}; # handler
unshift @INC, bless(sub {"dummy"}, "main::_DataPacker");
}
# END DATAPACK CODE
package main;
use 5.010001;
use strict;
#use warnings;
# load modules
### declare global variables
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2022-09-03'; # DATE
our $DIST = 'App-hr'; # DIST
our $VERSION = '0.268'; # VERSION
my $_pci_metas = {""=>{args=>{blink=>{cmdline_aliases=>{B=>{}},schema=>["bool",{req=>1}],summary=>"Return a blinking bar"},color=>{cmdline_aliases=>{c=>{}},schema=>["str",{req=>1}],summary=>"Specify a color (see Term::ANSIColor)"},height=>{cmdline_al...
our $_pci_meta_result_stream = 0;
our $_pci_meta_result_type;
our $_pci_meta_result_type_is_simple;
our $_pci_meta_skip_format = 0;
our $_pci_r = {naked_res=>0,read_config=>0,read_env=>0,subcommand_name=>""};
our %_pci_args;
### declare subroutines
sub _pci_err {
my $res = shift;
print STDERR "ERROR $res->[0]: $res->[1]\n";
exit $res->[0]-300;
}
sub _pci_json {
state $json = do {
if (eval { require JSON::XS; 1 }) { JSON::XS->new->canonical(1)->allow_nonref }
else { require JSON::PP; JSON::PP->new->canonical(1)->allow_nonref }
};
$json;
}
### begin code_before_parse_cmdline_options
### end code_before_parse_cmdline_options
### get arguments (from config file, env, command-line args
{
my %mentioned_args;
require Getopt::Long::EvenLess;
my $go_spec1 = {
'help|h|?' => sub { print "hr - Print horizontal bar on the terminal\n\nUsage:\n hr --help (or -h, -?)\n hr --version (or -v)\n hr [--blink|-B|--no-blink|--noblink] [--color=str|-c=str]\n [--height=int|-H=int] [--page-result[=program]] [--r...
'page-result:s' => sub { $_pci_r->{page_result} = 1; },
'version|v' => sub { no warnings 'once'; require App::hr; print "hr version ", "0.268", ($App::hr::DATE ? " ($App::hr::DATE)" : ''), "\n"; print " Generated by Perinci::CmdLine::Inline version 0.554 (2022-01-16)\n"; exit 0 },
};
my $go_spec2 = {
'B' => sub { $_pci_args{'blink'} = $_[1];
},
'H=s' => sub { $_pci_args{'height'} = $_[1];
},
'a=s' => sub { $_pci_args{'space_after'} = $_[1];
},
'b=s' => sub { $_pci_args{'space_before'} = $_[1];
},
'blink' => sub { $_pci_args{'blink'} = $_[1];
},
'c=s' => sub { $_pci_args{'color'} = $_[1];
},
'color=s' => sub { $_pci_args{'color'} = $_[1];
},
'height=s' => sub { $_pci_args{'height'} = $_[1];
},
'help|h|?' => sub { },
'no-blink' => sub { $_pci_args{'blink'} = 0;
},
'noblink' => sub { $_pci_args{'blink'} = 0;
},
'p=s' => sub { $_pci_args{'pattern'} = $_[1];
},
'page-result:s' => sub { },
'pattern=s' => sub { $_pci_args{'pattern'} = $_[1];
},
'r' => sub { my $code = sub{package App::hr;use warnings;use strict 'subs', 'vars';use feature 'say';$_[0]{'random_color'} = 1;$_[0]{'random_pattern'} = 1}; $code->(\%_pci_args);
},
'random-color' => sub { $_pci_args{'random_color'} = $_[1];
},
'random-pattern' => sub { $_pci_args{'random_pattern'} = $_[1];
},
'space-after=s' => sub { $_pci_args{'space_after'} = $_[1];
},
'space-before=s' => sub { $_pci_args{'space_before'} = $_[1];
},
'version|v' => sub { },
};
my $old_conf = Getopt::Long::EvenLess::Configure("pass_through");
Getopt::Long::EvenLess::GetOptions(%$go_spec1);
Getopt::Long::EvenLess::Configure($old_conf);
my $res = Getopt::Long::EvenLess::GetOptions(%$go_spec2);
# (# clause: is
# (($args->{"random_pattern"} ? 1:0) == (1 ? 1:0) ? 1 : (($_sahv_err //= "Must have the value 1"),0)))))
# ; if ($_sahv_err) { return [400, "Argument validation failed: $_sahv_err"] }
# } # if date arg exists
# $args->{"space_after"} //= 0;
# if (exists $args->{"space_after"}) {
# $_sahv_dpath = [];
# # req #0
# ((defined($args->{"space_after"})) ? 1 : (($_sahv_err //= "Required but not specified"),0))
#
# &&
#
# # check type 'int'
# ((Scalar::Util::Numeric::PP::isint($args->{"space_after"})) ? 1 : (($_sahv_err //= "Not of type integer"),0))
#
# &&
#
# (# clause: min
# (($args->{"space_after"} >= 0) ? 1 : (($_sahv_err //= "Must be at least 0"),0)))
# ; if ($_sahv_err) { return [400, "Argument validation failed: $_sahv_err"] }
# } # if date arg exists
# $args->{"space_before"} //= 0;
# if (exists $args->{"space_before"}) {
# $_sahv_dpath = [];
# # req #0
# ((defined($args->{"space_before"})) ? 1 : (($_sahv_err //= "Required but not specified"),0))
#
# &&
#
# # check type 'int'
# ((Scalar::Util::Numeric::PP::isint($args->{"space_before"})) ? 1 : (($_sahv_err //= "Not of type integer"),0))
#
# &&
#
# (# clause: min
# (($args->{"space_before"} >= 0) ? 1 : (($_sahv_err //= "Must be at least 0"),0)))
# ; if ($_sahv_err) { return [400, "Argument validation failed: $_sahv_err"] }
# } # if date arg exists
#
# # check required args
# return [400, "Missing required value for argument: blink"] if exists($args->{"blink"}) && !defined($args->{"blink"});
# return [400, "Missing required value for argument: color"] if exists($args->{"color"}) && !defined($args->{"color"});
# return [400, "Missing required value for argument: height"] if exists($args->{"height"}) && !defined($args->{"height"});
# return [400, "Missing required value for argument: pattern"] if exists($args->{"pattern"}) && !defined($args->{"pattern"});
# return [400, "Missing required value for argument: space_after"] if exists($args->{"space_after"}) && !defined($args->{"space_after"});
# return [400, "Missing required value for argument: space_before"] if exists($args->{"space_before"}) && !defined($args->{"space_before"});
# _pci_err([500, "Extraneous command-line argument(s): ".join(", ", @check_argv)]) if @check_argv;
# [200];
# } else { _pci_err([500, "Unknown subcommand1: $sc_name"]); }
#}
#1;
### Local/_pci_clean_json.pm ###
#sub _pci_clean_json { require Scalar::Util; require Clone::PP; use feature 'state'; state $cleanser = sub {
#my $data = shift;
#state %refs;
#state $ctr_circ;
#state $process_array;
#state $process_hash;
#if (!$process_array) { $process_array = sub { my $a = shift; for my $e (@$a) { my $ref=ref($e);
# if ($ref && $refs{ $e }++) { if (++$ctr_circ <= 1) { $e = Clone::PP::clone($e); redo } else { $e = 'CIRCULAR'; $ref = '' } }
# elsif ($ref eq 'Cpanel::JSON::XS::Boolean') { $e = $e ? 1:0; $ref = '' }
# elsif ($ref eq 'DateTime') { $e = $e->epoch; $ref = ref($e) }
# elsif ($ref eq 'JSON::PP::Boolean') { $e = $e ? 1:0; $ref = '' }
# elsif ($ref eq 'JSON::XS::Boolean') { $e = $e ? 1:0; $ref = '' }
# elsif ($ref eq 'Math::BigInt') { $e = $e->bstr; $ref = ref($e) }
# elsif ($ref eq 'Regexp') { $e = "$e"; $ref = "" }
# elsif ($ref eq 'SCALAR') { $e = ${ $e }; $ref = ref($e) }
# elsif ($ref eq 'Time::Moment') { $e = $e->epoch; $ref = ref($e) }
# elsif ($ref eq 'version') { $e = "$e"; $ref = "" }
# elsif (Scalar::Util::blessed($e)) { my $reftype = Scalar::Util::reftype($e); $e = $reftype eq "HASH" ? {%{ $e }} : $reftype eq "ARRAY" ? [@{ $e }] : $reftype eq "SCALAR" ? \(my $copy = ${ $e }) : $reftype eq "CODE" ? sub { goto &{ $e } } :(die "...
# my $reftype=Scalar::Util::reftype($e)//"";
# if ($reftype eq "ARRAY") { $process_array->($e) }
# elsif ($reftype eq "HASH") { $process_hash->($e) }
# elsif ($ref) { $e = $ref; $ref = "" }
#} } }
#if (!$process_hash) { $process_hash = sub { my $h = shift; for my $k (keys %$h) { my $ref=ref($h->{$k});
# if ($ref && $refs{ $h->{$k} }++) { if (++$ctr_circ <= 1) { $h->{$k} = Clone::PP::clone($h->{$k}); redo } else { $h->{$k} = 'CIRCULAR'; $ref = '' } }
# elsif ($ref eq 'Cpanel::JSON::XS::Boolean') { $h->{$k} = $h->{$k} ? 1:0; $ref = '' }
# elsif ($ref eq 'DateTime') { $h->{$k} = $h->{$k}->epoch; $ref = ref($h->{$k}) }
# elsif ($ref eq 'JSON::PP::Boolean') { $h->{$k} = $h->{$k} ? 1:0; $ref = '' }
# elsif ($ref eq 'JSON::XS::Boolean') { $h->{$k} = $h->{$k} ? 1:0; $ref = '' }
# elsif ($ref eq 'Math::BigInt') { $h->{$k} = $h->{$k}->bstr; $ref = ref($h->{$k}) }
# elsif ($ref eq 'Regexp') { $h->{$k} = "$h->{$k}"; $ref = "" }
# elsif ($ref eq 'SCALAR') { $h->{$k} = ${ $h->{$k} }; $ref = ref($h->{$k}) }
# elsif ($ref eq 'Time::Moment') { $h->{$k} = $h->{$k}->epoch; $ref = ref($h->{$k}) }
# elsif ($ref eq 'version') { $h->{$k} = "$h->{$k}"; $ref = "" }
# elsif (Scalar::Util::blessed($h->{$k})) { my $reftype = Scalar::Util::reftype($h->{$k}); $h->{$k} = $reftype eq "HASH" ? {%{ $h->{$k} }} : $reftype eq "ARRAY" ? [@{ $h->{$k} }] : $reftype eq "SCALAR" ? \(my $copy = ${ $h->{$k} }) : $reftype eq "...
# my $reftype=Scalar::Util::reftype($h->{$k})//"";
# if ($reftype eq "ARRAY") { $process_array->($h->{$k}) }
# elsif ($reftype eq "HASH") { $process_hash->($h->{$k}) }
# elsif ($ref) { $h->{$k} = $ref; $ref = "" }
#} } }
#%refs = (); $ctr_circ=0;
#for ($data) { my $ref=ref($_);
# if ($ref && $refs{ $_ }++) { if (++$ctr_circ <= 1) { $_ = Clone::PP::clone($_); redo } else { $_ = 'CIRCULAR'; $ref = '' } }
# elsif ($ref eq 'Cpanel::JSON::XS::Boolean') { $_ = $_ ? 1:0; $ref = '' }
# elsif ($ref eq 'DateTime') { $_ = $_->epoch; $ref = ref($_) }
# elsif ($ref eq 'JSON::PP::Boolean') { $_ = $_ ? 1:0; $ref = '' }
# elsif ($ref eq 'JSON::XS::Boolean') { $_ = $_ ? 1:0; $ref = '' }
# elsif ($ref eq 'Math::BigInt') { $_ = $_->bstr; $ref = ref($_) }
# elsif ($ref eq 'Regexp') { $_ = "$_"; $ref = "" }
# elsif ($ref eq 'SCALAR') { $_ = ${ $_ }; $ref = ref($_) }
# elsif ($ref eq 'Time::Moment') { $_ = $_->epoch; $ref = ref($_) }
# elsif ($ref eq 'version') { $_ = "$_"; $ref = "" }
# elsif (Scalar::Util::blessed($_)) { my $reftype = Scalar::Util::reftype($_); $_ = $reftype eq "HASH" ? {%{ $_ }} : $reftype eq "ARRAY" ? [@{ $_ }] : $reftype eq "SCALAR" ? \(my $copy = ${ $_ }) : $reftype eq "CODE" ? sub { goto &{ $_ } } :(die "...
# my $reftype=Scalar::Util::reftype($_)//"";
# if ($reftype eq "ARRAY") { $process_array->($_) }
# elsif ($reftype eq "HASH") { $process_hash->($_) }
# elsif ($ref) { $_ = $ref; $ref = "" }
#}
#$data
#}
#;; $cleanser->(shift) }
#1;
### Scalar/Util/Numeric/PP.pm ###
#package Scalar::Util::Numeric::PP;
#
#our $DATE = '2016-01-22'; # DATE
#our $VERSION = '0.04'; # VERSION
#
#use 5.010001;
#use strict;
#use warnings;
#
#require Exporter;
#our @ISA = qw(Exporter);
#our @EXPORT_OK = qw(
# isint
# isnum
# isnan
# isinf
# isneg
# isfloat
# );
#
#sub isint {
# local $_ = shift;
# return 0 unless defined;
# return 1 if /\A\s*[+-]?(?:0|[1-9][0-9]*)\s*\z/s;
# 0;
#}
#
#sub isnan($) {
# local $_ = shift;
# return 0 unless defined;
# return 1 if /\A\s*[+-]?nan\s*\z/is;
# 0;
#}
#
#sub isinf($) {
# local $_ = shift;
# return 0 unless defined;
# return 1 if /\A\s*[+-]?inf(?:inity)?\s*\z/is;
# 0;
#}
#
#sub isneg($) {
# local $_ = shift;
# return 0 unless defined;
( run in 0.646 second using v1.01-cache-2.11-cpan-9581c071862 )