The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Term::GentooFunctions - provides gentoo's einfo, ewarn, eerror, ebegin and eend.

SYNOPSIS

    use Term::GentooFunctions qw(:all)

    einfo "this is kinda neat...";

    ebegin "I hope this works...";
     ....
    eend $truefalse; # the result is backwards of gentoo; ie, 0 is bad, 1 is good.

PRINTS

einfo, ewarn, and eerror show informative lines with stars at the beginning colored green, yellow, and red (respectively).

BOOKENDS

ebegin and eend show the beginning and ends of things. ebegin also prints the given error message using einfo.

eend returns the result passed in for handy returns at the bottom of functions...

    sub eg {
        eend 0; # eg now returns a false!!  Huzzah!
    }

eend will use $_ if it is not passed any arguments.

DEATH

Print an error with eerror and exit(0x65).

INDENT

You can also use eindent and eoutdent to show trees of things happening, example:

    einfo "something"
    eindent 
    einfo "something else" # indented
    eoutdent
    einfo "something else (again)" # un-dented

DO

edo is an extra magic function that aggregates several of the functions above:

    use IPC::System::Simple qw(systemx);
    edo "removing file" => sub {

        systemx(qw(rm file));

    };

edo handles ebegin and eend automatically and catches errors for optional edie after execution. Nested edo functions will automatically eindent as well:

    edo test1 => sub {
        edo test2 => sub {
            systemx(qw(rm file));

        }
    }

Minor caveat: edie isn't catchable (see: eval) since it calls exit, therefore, inner death(s) should use die rather than edie.

SPINNERS

Strictly speaking, these functions aren't in the real Gentoo functions.sh script, but man they're handy.

    use Time::HiRes qw(sleep);
    start_spinner "testing the spinner";
    for (1 .. 20) {
        step_spinner; # spin the spinner
        # step_spinner "$_/20"; # optional msg arg
        sleep 0.1;
    }
    end_spinner 1; # works just like eend

SHELL

Term::GentooFunctions will use RC_INDENTATION and RC_DEFAULT_INDENT from Gentoo's /sbin/functions.sh. So you can eindent in a bash_script.sh and your perl_script.pl will use the indent level! However, to get it to work you must first export them to your perl scripts:

    export RC_INDENTATION RC_DEFAULT_INDENT 
    

Term::GentooFunctions will not be able to modify the indent level in a way that will propagate back up to bash -- that would technically be impossible through environment variables.

AUTHOR

Paul Miller <jettero@cpan.org>

I am using this software in my own projects... If you find bugs, please please please let me know. :) Actually, let me know if you find it handy at all. Half the fun of releasing this stuff is knowing that people use it.

LICENSE

Copyright (C) 2007-2010, Paul Miller,

This module is free software. You can redistribute it and/or modify it under the terms of the Artistic License 2.0.

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.

SEE ALSO

Term::Size, Term::ANSIColor, Term::ANSIScreen