| 1 | package MYDan::VSSH::Print; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use Carp; | ||
| 5 | |||
| 6 | use MYDan::Node; | ||
| 7 | use Term::ANSIColor qw(:constants :pushpop ); | ||
| 8 | $Term::ANSIColor::AUTORESET = 1; | ||
| 9 | |||
| 10 | use MYDan::VSSH::Execute; | ||
| 11 | |||
| 12 | our $BTLEN = 30; | ||
| 13 | |||
| 14 | sub new | ||
| 15 | { | ||
| 16 | my ( $this ) = @_; | ||
| 17 | bless +{}, ref $this || $this; | ||
| 18 | } | ||
| 19 | |||
| 20 | sub welcome | ||
| 21 | { | ||
| 22 | printf <<EOF; | ||
| 23 | _ | ||
| 24 | __ _____| | ___ ___ _ __ ___ ___ | ||
| 25 | \\ \\ /\\ / / _ \\ |/ __/ _ \\| '_ ` _ \\ / _ \ | ||
| 26 | \\ V V / __/ | (_| (_) | | | | | | __/ | ||
| 27 | \\_/\\_/ \\___|_|\\___\\___/|_| |_| |_|\\___| | ||
| 28 | |||
| 29 | EOF | ||
| 30 | |||
| 31 | } | ||
| 32 | |||
| 33 | sub yesno | ||
| 34 | { | ||
| 35 | while( 1 ) | ||
| 36 | { | ||
| 37 | print "Are you sure you want to run this command [y/n]:"; | ||
| 38 | my $in = <STDIN>; | ||
| 39 | next unless $in; | ||
| 40 | return 1 if $in eq "y\n"; | ||
| 41 | return 0 if $in eq "n\n"; | ||
| 42 | } | ||
| 43 | } | ||
| 44 | sub result | ||
| 45 | { | ||
| 46 | my ( $this, %r ) = @_; | ||
| 47 | |||
| 48 | print "\n"; | ||
| 49 | print PUSHCOLOR RED ON_GREEN "#" x $BTLEN, ' RESULT ', "#" x $BTLEN; | ||
| 50 | print "\n"; | ||
| 51 | |||
| 52 | my %re; | ||
| 53 | map{ push @{$re{$r{$_}}}, $_ }keys %r; | ||
| 54 | my $range = MYDan::Node->new( ); | ||
| 55 | print "=" x 68, "\n"; | ||
| 56 | map{ | ||
| 57 | |||
| 58 | printf "%s[", $range->load( $re{$_} )->dump; | ||
| 59 | my $count = scalar @{$re{$_}}; | ||
| 60 | |||
| 61 | my $exit = $_ && $_ =~ s/--- (\d+)\r?\n$// ? $1 : 1; | ||
| 62 | |||
| 63 | $exit ? print BOLD RED $count : print BOLD GREEN $count; | ||
| 64 | |||
| 65 | print "]:\n"; | ||
| 66 | |||
| 67 | $exit ? print BOLD RED "$_\n" : print BOLD GREEN "$_\n"; | ||
| 68 | |||
| 69 | print "=" x 68, "\n"; | ||
| 70 | }keys %re; | ||
| 71 | } | ||
| 72 | |||
| 73 | 1; |