Envy

 view release on metacpan or  search on metacpan

envy.IN  view on Meta::CPAN

#!/nw/dist/prod/bin/perl -w
use strict;
use vars qw($VERSION $running_under_some_shell);
$VERSION = '#VERSION#';
use Envy::DB;
use Envy::UI qw(cmd_2re alength);

warn "[WARNING: Envy version mismatch -- Envy::DB $Envy::DB::VERSION ne $VERSION]\n\n"
    if $Envy::DB::VERSION ne $VERSION;

my $is_unload=0;
my $is_csh=0;
my $is_showing=0;

sub sync_env {
    my ($db) = @_;
    my $failed = $db->commit;
    for ($db->warnings) { print }
    exit 1
	if $failed;
    $db->write_log if !$is_showing;
    my $old = select STDOUT if !$is_showing;
    for my $z ($db->to_sync()) {
	my ($k,$v) = @$z;
	# hope that single-quoting is enough XXX
	if (defined $v) {
	    if ($is_csh) {
		print "setenv $k '$v';\n";
	    } else {
		print "$k='$v'; export $k;\n";
	    }
	} else {
	    if ($is_csh) {
		print "unsetenv $k;\n";
	    } else {
		print "unset $k;\n";
	    }
	}
    }
    select $old if $old;
}

sub Huh {
    my ($why) = @_;
    if ($why) {
	print "** $why\n";
    } else {
	print "\n";
    }
    print "** Type 'envy help' for usage information. **\n";
}

sub Help {
    my $page = shift;
    if (!$page) {
	print "
  Envy $Envy::DB::VERSION -- Environment Dimension Manager

  Try:

     envy help usage    for command line arguments
     envy help author   for help writing .env files
     envy help path     for an explaination of search paths
     envy help env      for a list of envy specific environment variables
     envy help license  for licensing information

     envy help custom   for a description of \$HOME/.custom/ files [OPTIONAL]

  Send email to envy\@listbox.com for support.  Thanks!

";
    } elsif ($page eq 'usage') {
	print "
   list [<envy>]                - See descriptions
   paths [<envy>]               - Location of source files
   load <envy> [<envy> ...]     - Loads <envy>
   reload <envy> [<envy> ...]   - Unloads & reloads <envy>
   show <envy> [<envy> ...]     - Shows changes (shell env is unchanged)
   un <envy> [<envy> ...]       - Unloads <envy>
   unload all                   - Unloads all envies
   <str>                        - Lists/loads envies that match <str>
                                  AVOID IN SCRIPTS; CMD-LINE ONLY

   These options must be first on the command line:
   -csh                         - csh mode
   -quiet                       - Only report errors
   -v\\d                         - Set verbosity level
   -strict 1                    - Upgrade warnings to errors.
   --trace                      - Trace activity
   --debug                      - Maximum verbosity

";
    } elsif ($page eq 'custom') {
	require Envy::Conf;



( run in 1.762 second using v1.01-cache-2.11-cpan-39bf76dae61 )