Skip to content

Commit

Permalink
add skip-database option
Browse files Browse the repository at this point in the history
  • Loading branch information
roberto-butti committed Sep 7, 2020
1 parent d46c2e5 commit 205f362
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 19 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# Changelog

## 0.1.19 - WIP
### Add
- Add --skip-database in order to execute all checks except database and migration status (it is useful for example if the application it doesn't need the database);

### Change
- Code more PSR2 compliant (phpcs);


## 0.1.18 - 2020-09-05
### Add
- Support for Laravel 8
Expand Down
47 changes: 28 additions & 19 deletions src/Console/LaraLensCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use HiFolks\LaraLens\ResultLens;
use Illuminate\Console\Command;
use Illuminate\Support\Arr;
use Illuminate\Support\Composer;
use Illuminate\Support\Str;

class LaraLensCommand extends Command
Expand All @@ -24,6 +23,7 @@ class LaraLensCommand extends Command
{--width-label='.self::DEFAULT_WIDTH.' : width of column for label}
{--width-value='.self::DEFAULT_WIDTH.' : width of column for value}
{--style='.self::DEFAULT_STYLE.' : style of the output table ('.self::TABLE_STYLES.')}
{--skip-database : skip database check like connection and migration (if your laravel app doesn\'t need Database)}
';

protected $description = 'Show some application configurations.';
Expand Down Expand Up @@ -202,19 +202,28 @@ public function handle()
}
$columnSorting = $this->option("column-sort");
$showOptions= $this->option("show");

if (is_array($showOptions)) {
if (count($showOptions) >0) {
$show = self::OPTION_SHOW_NONE;
$show = (in_array("all", $showOptions)) ? $show | self::OPTION_SHOW_ALL : $show ;
$show = (in_array("config", $showOptions)) ? $show | self::OPTION_SHOW_CONFIGS : $show ;
$show = (in_array("runtime", $showOptions)) ? $show | self::OPTION_SHOW_RUNTIMECONFIGS : $show ;
$show = (in_array("connection", $showOptions)) ? $show | self::OPTION_SHOW_CONNECTIONS : $show ;
$show = (in_array("database", $showOptions)) ? $show | self::OPTION_SHOW_DATABASE : $show ;
$show = (in_array("migration", $showOptions)) ? $show | self::OPTION_SHOW_MIGRATION : $show ;
} else {
$show = self::OPTION_SHOW_ALL;
if (in_array("all", $showOptions)) {
$show = self::OPTION_SHOW_ALL;
$skipDatabases = $this->option("skip-database");
if ($skipDatabases) {
echo $show;
$show = self::OPTION_SHOW_ALL - self::OPTION_SHOW_DATABASE - self::OPTION_SHOW_MIGRATION;
}
} else {
$show = (in_array("config", $showOptions)) ? $show | self::OPTION_SHOW_CONFIGS : $show ;
$show = (in_array("runtime", $showOptions)) ? $show | self::OPTION_SHOW_RUNTIMECONFIGS : $show ;
$show = (in_array("connection", $showOptions)) ? $show | self::OPTION_SHOW_CONNECTIONS : $show ;
$show = (in_array("database", $showOptions)) ? $show | self::OPTION_SHOW_DATABASE : $show ;
$show = (in_array("migration", $showOptions)) ? $show | self::OPTION_SHOW_MIGRATION : $show ;

}
}
}

$this->widthLabel= $this->option("width-label");
$this->widthValue= $this->option("width-value");

Expand All @@ -224,16 +233,16 @@ public function handle()
}

switch ($op) {
case 'overview':
$this->overview($checkTable, $columnSorting, $show);
break;
case 'allconfigs':
$this->allConfigs();
break;

default:
$this->info("What you mean? try with 'php artisan laralens:diagnostic --help'");
break;
case 'overview':
$this->overview($checkTable, $columnSorting, $show);
break;
case 'allconfigs':
$this->allConfigs();
break;

default:
$this->info("What you mean? try with 'php artisan laralens:diagnostic --help'");
break;
}
}
}

0 comments on commit 205f362

Please sign in to comment.