Skip to content

Commit

Permalink
First stab at adding a plugin counter.
Browse files Browse the repository at this point in the history
  • Loading branch information
swelljoe committed Jul 27, 2017
1 parent f677bbc commit 30fe7e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/Virtualmin/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ sub run {

my @plugins = $self->_gather_plugins();
@plugins = $self->_order_plugins(@plugins);
my $total = $#plugins;
for (@plugins) {
my $pkg = "Virtualmin::Config::Plugin::$_";
load $pkg || die "Loading Plugin failed: $_";
my $plugin = $pkg->new();
$plugin->actions();
my $plugin = $pkg->new( total => $total );
$plugin->actions($total);
if ($self->{test} && $plugin->can('tests')) {
$plugin->tests();
}
Expand Down
7 changes: 6 additions & 1 deletion lib/Virtualmin/Config/Plugin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ our $spinner;
our $trust_unknown_referers = 1;
our $error_must_die = 1;

our $count = 1;

my $log = Log::Log4perl->get_logger("virtualmin-config-system");

sub new {
my ($class, %args) = @_;

my $self = {name => $args{name}, depends => $args{depends}};
my $self = {name => $args{name}, depends => $args{depends}, total => $args{ total }};
bless $self, $class;

return $self;
Expand All @@ -46,6 +48,9 @@ sub spin {
my $self = shift;
my $name = $self->name();
my $message = shift // "Configuring " . $name;
$message = "[" . YELLOW . $count . RESET . "/" . GREEN . $self->{total} .
RESET . "] " . $message;
$count++;
$log->info($message);
$spinner = Term::Spinner::Color->new();
$message = $message . " " x (79 - length($message) - $spinner->{'last_size'});
Expand Down

0 comments on commit 30fe7e3

Please sign in to comment.