Padre

 view release on metacpan or  search on metacpan

script/padre  view on Meta::CPAN

#!/usr/bin/perl

use 5.010000;
use strict;
use warnings;
use Carp ();

our $VERSION = '1.01';

use constant WIN32 => !!( $^O eq 'MSWin32' and $^X =~ /wperl\.exe/ );

local $| = 1;
local $SIG{__DIE__} =
	$ENV{PADRE_DIE}
	? sub { print STDERR Carp::longmess "\nDIE: @_\n" . ( "-" x 80 ) . "\n" }
	: $SIG{__DIE__};

# Must run using wxPerl on OS X.
if ( $^O eq 'darwin' and $^X !~ m{/wxPerl} ) {
	require File::Which;
	require File::Basename;
	require File::Spec;

	my $this_perl = File::Which::which($^X) || $^X;
	if ( -l $this_perl ) {
		my $link = readlink $this_perl;
		$this_perl = $link if $link;
	}

	my $dir = File::Basename::dirname($this_perl);
	my $wx_perl = File::Spec->catfile( $dir, 'wxPerl' );
	my $perl =
		  $wx_perl && -e $wx_perl && -x _
		? $wx_perl
		: File::Which::which('wxPerl');
	chomp($perl);
	if ( -e $perl ) {
		warn "spawning 'wxPerl' interpreter for OS X\n";
		system( $perl, '-S', $0, @ARGV );
	} else {
		warn "padre cannot find wxPerl executable (which it requires on OS X)\n";
	}
	exit 0;
}

# Disable overlay scrollbar on Linux.
# Done ugly this way to satisfy Perl::Critic (grrr)
local $ENV{LIBOVERLAY_SCROLLBAR} = ( $^O eq 'linux' ) ? 0 : $ENV{LIBOVERLAY_SCROLLBAR};

# Handle special command line cases early, because options like --home
# MUST be processed before the Padre.pm library is loaded.
my $USAGE       = '';
my $SHOWVERSION = '';
my $HOME        = undef;
my $RESET       = undef;
my $SESSION     = undef;
my $PRELOAD     = undef;
my $DESKTOP     = undef;
my $ACTIONS     = undef;
my $LOCALE      = undef;
if ( grep {/^-/} @ARGV ) {

	# Avoid loading Getopt::Long entirely if we can,
	# sneakily saving a meg or so of RAM.
	require Getopt::Long;
	Getopt::Long::GetOptions(
		'help|usage'    => \$USAGE,
		'version'       => \$SHOWVERSION,
		'home=s'        => \$HOME,
		'reset'         => \$RESET,
		'session=s'     => \$SESSION,
		'desktop'       => \$DESKTOP,
		'actionqueue=s' => \$ACTIONS,
		'locale=s'      => \$LOCALE,

		# Keep this sekrit for now --ADAMK
		'preload' => \$PRELOAD,
	) or $USAGE = 1;
}





#####################################################################
# Special Execution Modules

# Padre command line usage
if ($USAGE) {
	print <<"END_USAGE";
Usage: $0 [FILENAMES]

--help              Shows this help message
--home=dir          Forces Padre "home" directory to a specific location
--reset             Flush entire local config directory and reset to defaults
--session=name      Open given session during Padre startup
--version           Prints Padre version and quits
--desktop           Integrate Padre with your desktop
--actionqueue=list  Run a list of comma-separated actions after Padre startup
--locale=name       Locale name to use

END_USAGE
	exit(1);
}

# Lock in the home and constants, which are needed for everything else



( run in 3.684 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )