use List::Util qw(any);
use constant CONFIG_FILE => '/etc/newslash/newslash.conf';
+has subcommand => "";
# This method will run once at server start
sub startup {
my $app = shift;
+ if ($ARGV[0]) {
+ $app->subcommand($ARGV[0]);
+ }
+
# add commands in Newslash::Command
push @{$app->commands->namespaces}, 'Newslash::Command';
$app->plugin('Newslash::Plugin::YAMLConfig', file => CONFIG_FILE);
}
else {
- if ($ARGV[0] && $ARGV[0] eq "configdump") {
+ if ($app->subcommand eq "configdump") {
$app->plugin('Newslash::Plugin::YAMLConfig', default => {});
}
else {
# check if 'maintenance' mode
my $maintenance_mode = 0;
- if (!$ARGV[0]
- || any { $ARGV[0] eq $_ } qw[configdump configimport databaseinit
- testdatainsert useradd usermod
- ]) {
+ if (!$app->subcommand
+ || any { $app->subcommand eq $_ } qw[configdump configimport databaseinit
+ testdatainsert useradd usermod
+ ]) {
$maintenance_mode = 1;
}