App-Licensecheck

 view release on metacpan or  search on metacpan

bin/licensecheck  view on Meta::CPAN

);

GetOptions( \%OPT, @OPT ) or pod2usage(2);

if ( $OPT{trace} ) {
	Log::Any::Adapter->set(
		'Screen', use_color => $USE_COLOR,
		default_level => 'trace'
	);
}
elsif ( $OPT{debug} ) {
	Log::Any::Adapter->set(
		'Screen', use_color => $USE_COLOR,
		default_level => 'debug'
	);
}
elsif ( $OPT{verbose} ) {
	Log::Any::Adapter->set(
		'Screen', use_color => $USE_COLOR,
		default_level => 'info'
	);
}
elsif ( $OPT{quiet} ) {
	Log::Any::Adapter->set(
		'Screen', use_color => $USE_COLOR,
		default_level => 'error'
	);
}
else {
	Log::Any::Adapter->set( 'Screen', use_color => $USE_COLOR );
}

pod2usage(1) if ( $OPT{help} );
if ( $OPT{version} ) { version(); exit 0; }

my @schemes;
if ( $OPT{'shortname-scheme'} ) {
	@schemes = split /[\s,]+/, $OPT{'shortname-scheme'};
}
elsif ($OPT{'deb-machine'}
	|| $OPT{'deb-fmt'}
	|| $OPT{'list-licenses'}
	|| $OPT{'list-naming-schemes'} )
{
	@schemes = qw(debian spdx);
}

# TODO: skip when future option '--strict-schemes' is enabled
push @schemes, 'internal'
	if @schemes;

my $naming;
if (@schemes) {
	$naming = String::License::Naming::Custom->new( schemes => \@schemes );
}
else {
	$naming = String::License::Naming::Custom->new( schemes => \@schemes );
}

if ( $OPT{'list-licenses'} ) {
	say for $naming->list_licenses;
	exit 0;
}

if ( $OPT{'list-naming-schemes'} ) {
	say for $naming->list_schemes;
	exit 0;
}

if ( $OPT{text} ) {
	$log->warn('option -text ignored: obsolete');    # since 2015
}
if ( $OPT{noconf} ) {
	$log->warn('option --no-conf ingored: obsolete');    # since 2016
}
if ( $OPT{noverbose} ) {
	$log->warn('option --no-verbose ignored: obsolete');    # since 2021
}

pod2usage("$progname: No paths provided.")
	unless @ARGV;

my $app = App::Licensecheck->new(

	# parse
	top_lines => $OPT{lines},
	end_bytes => $OPT{tail},
	encoding  => $OPT{encoding},

	# report
	naming => $naming,
);

my $default_check_regex = q!
	/[\w-]+$ # executable scripts or README like file
	|\.( # search for file suffix
		c(c|pp|xx)? # c and c++
		|h(h|pp|xx)? # header files for c and c++
		|S
		|css|less # HTML css and similar
		|f(77|90)?
		|go
		|groovy
		|lisp
		|scala
		|clj
		|p(l|m)?6?|t|xs|pod6? # perl5 or perl6
		|sh
		|php
		|py(|x)
		|rb
		|java
		|js
		|vala
		|el
		|sc(i|e)
		|cs
		|pas
		|inc
		|dtd|xsl
		|mod
		|m
		|md|markdown
		|tex
		|mli?
		|(c|l)?hs



( run in 0.869 second using v1.01-cache-2.11-cpan-bbe5e583499 )