CLI-Helpers
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/CLI/Helpers.pm view on Meta::CPAN
package CLI::Helpers;
# ABSTRACT: Subroutines for making simple command line scripts
# RECOMMEND PREREQ: App::Nopaste
# RECOMMEND PREREQ: Term::ReadLine::Gnu
use strict;
use feature qw(state);
use warnings;
use Capture::Tiny qw(capture);
use File::Basename;
use Getopt::Long qw(GetOptionsFromArray :config pass_through);
use IO::Interactive qw( is_interactive );
use Module::Load qw(load);
use Ref::Util qw(is_ref is_arrayref is_hashref);
use Sys::Syslog qw(:standard);
use Term::ANSIColor 2.01 qw(color colored colorstrip);
use Term::ReadKey;
use Term::ReadLine;
use YAML;
our $VERSION = '2.0'; # VERSION
# Capture ARGV at Load
my @ORIG_ARGS;
BEGIN {
@ORIG_ARGS = @ARGV;
}
require Exporter;
our @ISA = qw(Exporter);
my @output_tags = qw(output verbose debug debug_var cli_helpers_initialize);
my @input_tags = qw(prompt menu text_input confirm pwprompt);
our @EXPORT_OK = ( @output_tags, @input_tags );
our %EXPORT_TAGS = (
all => [@output_tags,@input_tags],
input => \@input_tags,
output => \@output_tags,
);
my $ARGV_AT_INIT = 0;
my $COPY_ARGV = 0;
our $_init_complete = 0;
sub import {
my (@args) = @_;
my @import = ();
# We need to process the config options
foreach my $arg ( @args ) {
if( $arg eq 'delay_argv' ) {
$ARGV_AT_INIT = 0;
}
elsif( $arg eq 'preprocess_argv' ) {
$ARGV_AT_INIT = 1;
}
elsif( $arg eq 'copy_argv' ) {
$COPY_ARGV = 1;
}
# Not a config option, pass through
else {
push @import, $arg;
}
}
CLI::Helpers->export_to_level( 1, @import );
}
{
## no critic (ProhibitNoWarnings)
no warnings;
INIT {
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.126 second using v1.00-cache-2.02-grep-82fe00e-cpan-c30982ac1bc3 )