Heray-Was-Here
Server : Apache
System : Linux vps43555.mylogin.co 3.10.0-1160.53.1.vz7.185.3 #1 SMP Tue Jan 25 12:49:12 MSK 2022 x86_64
User : redsea ( 60651)
PHP Version : 7.4.32
Disable Function : NONE
Directory :  /usr/local/bin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/local/bin/yamlpp-highlight
#!/usr/bin/perl
use strict;
use warnings;

use YAML::PP::Highlight;
use Encode;
use Getopt::Long;

GetOptions(
    'help|h' => \my $help,
    'expand-tabs|et!' => \my $expand_tabs,
) or usage(1);

$expand_tabs = 1 unless defined $expand_tabs;

usage(0) if $help;

my ($file) = @ARGV;
my $yaml;

unless ($file) {
    $yaml = do { local $/; <STDIN> };
    $yaml = decode_utf8($yaml);
}

my $error;
my $tokens;
if (defined $file) {
    ($error, $tokens) = YAML::PP::Parser->yaml_to_tokens( file => $file );
}
else {
    ($error, $tokens) = YAML::PP::Parser->yaml_to_tokens( string => $yaml );
}
my $highlighted = YAML::PP::Highlight->ansicolored($tokens, expand_tabs => $expand_tabs);
print encode_utf8 $highlighted;
if ($error) {
    die $error;
}

sub usage {
    my ($rc) = @_;
    print <<"EOM";
Usage:

    $0 [options] < file
    $0 [options] file

Options:
    --expand-tabs    --et         Expand tabs to 8 spaces (default true)
    --no-expand-tabs --no-et      Don't expand tabs
EOM
    exit $rc;
}


Hry