App-ZodiacUtils

 view release on metacpan or  search on metacpan

script/zodiac-of  view on Meta::CPAN

my $go_spec2 = {
    'date=s@' => sub {         if ($mentioned_args{'dates'}++) { push @{ $_pci_args{'dates'} }, $_[1] } else { $_pci_args{'dates'} = [$_[1]] }
 },
    'dates-json=s' => sub {         $_pci_args{'dates'} = _pci_json()->decode($_[1]);
 },
    'format=s' => sub {  },
    'help|h|?' => sub {  },
    'json' => sub {  },
    'naked-res' => sub {  },
    'no-naked-res|nonaked-res' => sub {  },
    'page-result:s' => sub {  },
    '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);
_pci_err([500, "GetOptions failed"]) unless $res;
}

### check arguments

{
require Local::_pci_check_args; my $res = _pci_check_args(\%_pci_args);
_pci_err($res) if $res->[0] != 200;
$_pci_r->{args} = \%_pci_args;
}

### call function

{
my $sc_name = $_pci_r->{subcommand_name};
if ($sc_name eq "") {
    $_pci_meta_result_type = "";
    require App::ZodiacUtils;
    eval { $_pci_r->{res} = App::ZodiacUtils::zodiac_of(%_pci_args) };
    if ($@) { $_pci_r->{res} = [500, "Function died: $@"] }
    $_pci_r->{res} = [200, "OK (envelope added by Perinci::CmdLine::Inline)", $_pci_r->{res}];
}
}

### format & display result

{
my $fh;
if ($_pci_r->{page_result} // $ENV{PAGE_RESULT} // $_pci_r->{res}[3]{"cmdline.page_result"}) {
my $pager = $_pci_r->{pager} // $_pci_r->{res}[3]{"cmdline.pager"} // $ENV{PAGER} // "less -FRSX";
open $fh, "| $pager";
} else {
$fh = \*STDOUT;
}
my $fres;
my $save_res; if (exists $_pci_r->{res}[3]{"cmdline.result"}) { $save_res = $_pci_r->{res}[2]; $_pci_r->{res}[2] = $_pci_r->{res}[3]{"cmdline.result"} }
my $is_success = $_pci_r->{res}[0] =~ /\A2/ || $_pci_r->{res}[0] == 304;
my $is_stream = $_pci_r->{res}[3]{stream} // $_pci_meta_result_stream // 0;
if ($is_success && (0 || $_pci_meta_skip_format || $_pci_r->{res}[3]{"cmdline.skip_format"})) { $fres = $_pci_r->{res}[2] }
elsif ($is_success && $is_stream) {}
else { require Local::_pci_clean_json; require Perinci::Result::Format::Lite; $is_stream=0; _pci_clean_json($_pci_r->{res}); $fres = Perinci::Result::Format::Lite::format($_pci_r->{res}, ($_pci_r->{format} // $_pci_r->{res}[3]{"cmdline.default_format...

my $use_utf8 = $_pci_r->{res}[3]{"x.hint.result_binary"} ? 0 : 0;
if ($use_utf8) { binmode STDOUT, ":encoding(utf8)" }
if ($is_stream) {
    my $code = $_pci_r->{res}[2]; if (ref($code) ne "CODE") { die "Result is a stream but no coderef provided" } if ($_pci_meta_result_type_is_simple) { while(defined(my $l=$code->())) { print $fh $l; print $fh "\n" unless $_pci_meta_result_type eq "...
} else {
    print $fh $fres;
}
if (defined $save_res) { $_pci_r->{res}[2] = $save_res }
}

### exit

{
my $status = $_pci_r->{res}[0];
my $exit_code = $_pci_r->{res}[3]{"cmdline.exit_code"} // ($status =~ /200|304/ ? 0 : ($status-300));
exit($exit_code);
}

=pod

=encoding UTF-8

=head1 NAME

zodiac-of - Show zodiac for a date

=head1 VERSION

This document describes version 0.115 of main (from Perl distribution App-ZodiacUtils), released on 2020-09-14.

=head1 SYNOPSIS

Usage:

 % zodiac-of [--format=name] [--json] [--(no)naked-res]
     [--page-result[=program]] <dates> ...

Examples:

 % zodiac-of 2015-06-15
 gemini

Multiple dates:

 % zodiac-of 2015-12-17 2015-12-29
 +------------+-------------+
 | 2015-12-17 | sagittarius |
 | 2015-12-29 | capricornus |
 +------------+-------------+

=head1 OPTIONS

C<*> marks required options.

=head2 Main options

=over

=item B<--date>=I<s@>*

Dates.

script/zodiac-of  view on Meta::CPAN

#Where arguments were not supported in the original release,
#the first supporting version is noted.
#
#=over 4
#
#
#=item *
#
#rows
#
#Takes an array reference which should contain one or more rows
#of data, where each row is an array reference.
#
#
#=item *
#
#header_row
#
#If given a true value, the first row in the data will be interpreted
#as a header row, and separated from the rest of the table with a ruled line.
#
#
#=item *
#
#separate_rows
#
#If given a true value, a separator line will be drawn between every row in
#the table,
#and a thicker line will be used for the header separator.
#
#=item *
#
#top_and_tail
#
#If given a true value, then the top and bottom border lines will be skipped.
#This reduces the vertical height of the generated table.
#
#Added in 0.04.
#
#=item *
#
#align
#
#This takes an array ref with one entry per column,
#to specify the alignment of that column.
#Legal values are 'l', 'c', and 'r'.
#You can also specify a single alignment for all columns.
#ANSI escape codes are handled.
#
#Added in 1.00.
#
#=item *
#
#style
#
#Specifies the format of the output table.
#The default is C<'classic'>,
#but other options are C<'boxrule'> and C<'norule'>.
#
#If you use the C<boxrule> style,
#you'll probably need to run C<binmode(STDOUT, ':utf8')>.
#
#Added in 1.00.
#
#
#=item *
#
#indent
#
#Specify an indent that should be prefixed to every line
#of the generated table.
#This can either be a string of spaces,
#or an integer giving the number of spaces wanted.
#
#Added in 1.00.
#
#=item *
#
#compact
#
#If set to a true value then we omit the single space padding on either
#side of every column.
#
#Added in 1.00.
#
#=back
#
#
#=head2 EXAMPLES
#
#If you just pass the data and no other options:
#
# generate_table(rows => $rows);
#
#You get minimal ruling:
#
# +------------+---------+-------+
# | Pokemon    | Type    | Count |
# | Abra       | Psychic | 5     |
# | Ekans      | Poison  | 123   |
# | Feraligatr | Water   | 5678  |
# +------------+---------+-------+
#
#If you want a separate header, set the header_row option to a true value,
#as shown in the SYNOPSIS.
#
#To take up fewer lines,
#you can miss out the top and bottom rules,
#by setting C<top_and_tail> to a true value:
#
# generate_table(rows => $rows, header_row => 1, top_and_tail => 1);
#
#This will generate the following:
#
# | Pokemon    | Type    | Count |
# +------------+---------+-------+
# | Abra       | Psychic | 5     |
# | Ekans      | Poison  | 123   |
# | Feraligatr | Water   | 5678  |
#
#If you want a more stylish looking table,
#set the C<style> parameter to C<'boxrule'>:
#
# binmode(STDOUT,':utf8');
# generate_table(rows => $rows, header_row => 1, style => 'boxrule');
#
#This uses the ANSI box rule characters.
#Note that you will need to ensure UTF output.
#
# ┌────────────┬─────────┬───────┐
# │ Pokemon    │ Type    │ Count │
# ├────────────┼─────────┼───────┤
# │ Abra       │ Psychic │ 5     │
# │ Ekans      │ Poison  │ 123   │
# │ Feraligatr │ Water   │ 5678  │
# └────────────┴─────────┴───────┘
#
#You might want to right-align numeric values:
#
# generate_table( ... , align => [qw/ l l r /] );
#
#The C<align> parameter can either take an arrayref,
#or a string with an alignment to apply to all columns:
#
# ┌────────────┬─────────┬───────┐
# │ Pokemon    │ Type    │ Count │
# ├────────────┼─────────┼───────┤
# │ Abra       │ Psychic │     5 │
# │ Ekans      │ Poison  │   123 │
# │ Feraligatr │ Water   │  5678 │
# └────────────┴─────────┴───────┘
#
#If you're using the boxrule style,
#you might feel you can remove the padding on either side of every column,
#done by setting C<compact> to a true value:
#
# ┌──────────┬───────┬─────┐
# │Pokemon   │Type   │Count│
# ├──────────┼───────┼─────┤
# │Abra      │Psychic│    5│
# │Ekans     │Poison │  123│
# │Feraligatr│Water  │ 5678│
# └──────────┴───────┴─────┘
#
#You can also ask for a rule between each row,
#in which case the header rule becomes stronger.
#This works best when combined with the boxrule style:
#
# generate_table( ... , separate_rows => 1 );
#
#Which results in the following:
#
# ┌────────────┬─────────┬───────┐
# │ Pokemon    │ Type    │ Count │
# ╞════════════╪═════════╪═══════╡
# │ Abra       │ Psychic │     5 │
# ├────────────┼─────────┼───────┤
# │ Ekans      │ Poison  │   123 │
# ├────────────┼─────────┼───────┤
# │ Feraligatr │ Water   │  5678 │
# └────────────┴─────────┴───────┘
#
#You can use this with the other styles,
#but I'm not sure you'd want to.



( run in 0.783 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )