CPAN-Mini-ProjectDocs

 view release on metacpan or  search on metacpan

scripts/mcd  view on Meta::CPAN

die "Can't find CPAN::Mini at '$cpan_mini'!" unless -e $cpan_mini ;

my $mcd_cache = home() . '/.cpan_mini_pod2projdoc' ;
mkdir $mcd_cache ;

#----------------------------------

generate_cache($cpan_mini, $mcd_cache) ;

if($search)
	{
	search_modules($cpan_mini, $mcd_cache, $module) ;
	}
else
	{
	my $module_distribution = get_module_distribution($cpan_mini, $mcd_cache, $module) ;
	
	if(defined $module_distribution)
		{
		print "Found $module in '$module_distribution'.\n"  unless $search ;
		
		if($browse)
			{
			my $html_documentation_location = generate_html($cpan_mini, $mcd_cache, $module_distribution, $html_index) ;
			
			my $browser = $user_defined_browser || $ENV{BROWSER} || ($html_index ? 'elinks' : 'firefox') ;
			system($browser, $html_documentation_location) == 0 or die "can't start browser!" ;
			}
		}
	else
		{
		print "'$module' not found! Try the -s option.\n" ;
		}
	}
}

#---------------------------------------------------------------------------------------------------------

sub get_options
{

#~ =head2 get_options(@arguments)

#~ Parses the command line for the module to search and user defined options.

#~ I<Arguments>

#~ =over 2 

#~ =item @arguments - the command line arguments

#~ =back

#~ I<Returns> -  A list containing the module to search followed by the options accepted by this command

#~ I<Exceptions> - exits if an invalid option is passed

#~ =cut

my (@arguments) = @_ ;
local @ARGV = @arguments ;

my ($search, $browse, $html_index, $user_defined_browser, $cpan_mini_user_location) ;

unless
	(
	GetOptions
		(
		'h|help' => \&display_help,
		's|search' => \$search,
		'b|browse' => \$browse,
		'browser=s' => \$user_defined_browser,
		'html_index' => \$html_index,
		'cpan_mini=s' => \$cpan_mini_user_location,
		)
	)
	{
	die "Error: Invalid Option! Try --help.\n" ;
	}

my $module = $ARGV[0] or die "Error: I need a module name on the command line! Try --help.\n" ;

return ($module, $search, $browse, $html_index, $user_defined_browser, $cpan_mini_user_location) ;
}

#---------------------------------------------------------------------------------------------------------

sub display_help
{

#~ =head2 display_help()

#~ I<Arguments> - None

#~ I<Returns> - Nothing

#~ I<Exceptions> - exits with status code B<1>

#~ =cut

my ($this_script) = ($PROGRAM_NAME =~m/(.*)/sxm ) ;

print {*STDERR} `perldoc $this_script`  or croak 'Error: Can\'t display help!' ; ## no critic (InputOutput::ProhibitBacktickOperators)
exit(1) ;
}

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.915 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )