Skip to content

Commit

Permalink
Make code comply with default perlcritic settings, remove use of IFBU…
Browse files Browse the repository at this point in the history
…ILT & IFUNBUILT, add some guide comments
  • Loading branch information
perlancar committed Aug 18, 2021
1 parent a1c2139 commit b8760bd
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 53 deletions.
14 changes: 9 additions & 5 deletions lib/Perinci/CmdLine/Base.pm
@@ -1,17 +1,21 @@
## no critic: ControlStructures::ProhibitUnreachableCode
package Perinci::CmdLine::Base;

# AUTHORITY
# DATE
# DIST
# VERSION

# put pragmas + Log::ger here
use 5.010001;
use strict;
use warnings;
use Log::ger;

# put other modules alphabetically here
use IO::Interactive qw(is_interactive);

# put global variables alphabetically here
# AUTHORITY
# DATE
# DIST
# VERSION

# this class can actually be a role instead of base class for pericmd &
# pericmd-lite, but Mo is more lightweight than Role::Tiny (also R::T doesn't
# have attributes), Role::Basic, or Moo::Role.
Expand Down
20 changes: 12 additions & 8 deletions lib/Perinci/CmdLine/Lite.pm
@@ -1,20 +1,24 @@
package Perinci::CmdLine::Lite;

# AUTHORITY
# DATE
# DIST
# VERSION

# put pragmas + Log::ger here
use 5.010001;
# use strict; # already enabled by Mo
# use warnings; # already enabled by Mo
use Log::ger;

# put other modules alphabetically here
use IO::Interactive qw(is_interactive);
use List::Util qw(first);
use Mo qw(build default);
#use Moo;
extends 'Perinci::CmdLine::Base';

# put global variables alphabetically here
# AUTHORITY
# DATE
# DIST
# VERSION

# when debugging, use this instead of the above because Mo doesn't give clear
# error message if base class has errors.
#use parent 'Perinci::CmdLine::Base';
Expand Down Expand Up @@ -114,7 +118,7 @@ my $setup_progress;
sub _setup_progress_output {
my $self = shift;

return unless $ENV{PROGRESS} // (-t STDOUT);
return unless $ENV{PROGRESS} // is_interactive(*STDOUT);

require Progress::Any::Output;
Progress::Any::Output->set("TermProgressBarColor");
Expand Down Expand Up @@ -260,7 +264,7 @@ sub hook_before_action {
name => 'validate_args',
r => $r,
on_success => sub {
no strict 'refs';
no strict 'refs'; ## no critic: TestingAndDebugging::ProhibitNoStrict

# to be cheap, we simply use "$ref" as key as cache key. to be
# proper, it should be hash of serialized content.
Expand Down Expand Up @@ -542,7 +546,7 @@ sub action_subcommands {
}

sub action_version {
no strict 'refs';
no strict 'refs'; ## no critic: TestingAndDebugging::ProhibitNoStrict

my ($self, $r) = @_;

Expand Down
17 changes: 9 additions & 8 deletions lib/Perinci/CmdLine/Plugin/DisablePlugin.pm
@@ -1,17 +1,18 @@
package Perinci::CmdLine::Plugin::DisablePlugin;

# AUTHORITY
# DATE
# DIST
# VERSION

# IFUNBUILT
# put pragmas + Log::ger here
use strict;
use warnings;
# END IFUNBUILT
use parent 'Perinci::CmdLine::PluginBase';
use Log::ger;

use parent 'Perinci::CmdLine::PluginBase';
# put other modules alphabetically here

# put global variables alphabetically here
# AUTHORITY
# DATE
# DIST
# VERSION

sub meta {
return {
Expand Down
17 changes: 9 additions & 8 deletions lib/Perinci/CmdLine/Plugin/DumpArgs.pm
@@ -1,18 +1,19 @@
package Perinci::CmdLine::Plugin::DumpArgs;

# AUTHORITY
# DATE
# DIST
# VERSION

# IFUNBUILT
# put pragmas + Log::ger here
use strict;
use warnings;
# END IFUNBUILT
use Log::ger;

use parent 'Perinci::CmdLine::PluginBase';

# put other modules alphabetically here

# put global variables alphabetically here
# AUTHORITY
# DATE
# DIST
# VERSION

sub meta {
return {
summary => 'Dump command-line arguments ($r->{args}), by default after argument validation',
Expand Down
17 changes: 9 additions & 8 deletions lib/Perinci/CmdLine/Plugin/DumpR.pm
@@ -1,18 +1,19 @@
package Perinci::CmdLine::Plugin::DumpR;

# AUTHORITY
# DATE
# DIST
# VERSION

# IFUNBUILT
# put pragmas + Log::ger here
use strict;
use warnings;
# END IFUNBUILT
use Log::ger;

use parent 'Perinci::CmdLine::PluginBase';

# put other modules alphabetically here

# put global variables alphabetically here
# AUTHORITY
# DATE
# DIST
# VERSION

sub meta {
return {
summary => 'Dump request stash ($r), by default after action',
Expand Down
17 changes: 9 additions & 8 deletions lib/Perinci/CmdLine/Plugin/DumpRes.pm
@@ -1,18 +1,19 @@
package Perinci::CmdLine::Plugin::DumpRes;

# AUTHORITY
# DATE
# DIST
# VERSION

# IFUNBUILT
# put pragmas + Log::ger here
use strict;
use warnings;
# END IFUNBUILT
use Log::ger;

use parent 'Perinci::CmdLine::PluginBase';

# put other modules alphabetically here

# put global variables alphabetically here
# AUTHORITY
# DATE
# DIST
# VERSION

sub meta {
return {
summary => 'Dump result ($r->{res}), by default after action',
Expand Down
15 changes: 8 additions & 7 deletions lib/Perinci/CmdLine/PluginBase.pm
@@ -1,17 +1,18 @@
package Perinci::CmdLine::PluginBase;

# AUTHORITY
# DATE
# DIST
# VERSION

# IFUNBUILT
# put pragmas + Log::ger here
use strict 'subs', 'vars';
use warnings;
# END IFUNBUILT

# put other modules alphabetically here
#require Perinci::CmdLine::Base;

# put global variables alphabetically here
# AUTHORITY
# DATE
# DIST
# VERSION

sub new {
my ($class, %args) = (shift, @_);
bless \%args, $class;
Expand Down
3 changes: 2 additions & 1 deletion t/suite.t
Expand Up @@ -2,13 +2,14 @@

# run the Test::Perinci::CmdLine test suite

# put pragmas + test modules (sorted alphabetically) here
use 5.010;
use strict;
use warnings;

use Test::More 0.98;
use Test::Perinci::CmdLine;

# put other modules here
pericmd_ok(
class => 'Perinci::CmdLine::Lite',
exclude_tags => [
Expand Down

0 comments on commit b8760bd

Please sign in to comment.