Skip to content

Commit

Permalink
specify commands that will not be available on web interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
systemsolutionweb committed Mar 31, 2023
1 parent d7ea4f7 commit d6c08be
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/Package.php
Expand Up @@ -27,6 +27,8 @@ class Package

public array $commands = [];

public array $consoleCommands = [];

public array $viewComponents = [];

public array $sharedViewData = [];
Expand Down Expand Up @@ -70,7 +72,7 @@ public function hasInstallCommand($callable): static

$callable($installCommand);

$this->commands[] = $installCommand;
$this->consoleCommands[] = $installCommand;

return $this;
}
Expand Down Expand Up @@ -163,9 +165,9 @@ public function hasMigrations(...$migrationFileNames): static
return $this;
}

public function hasCommand(string $commandClassName): static
public function hasCommand(string $commandClassName, bool $justConsole = false): static
{
$this->commands[] = $commandClassName;
$this->{$justConsole ? 'consoleCommands' : 'commands'}[] = $commandClassName;

return $this;
}
Expand All @@ -177,6 +179,18 @@ public function hasCommands(...$commandClassNames): static
return $this;
}

public function hasConsoleCommand(string $commandClassName): static
{
return $this->hasCommand($commandClassName, true);
}

public function hasConsoleCommands(...$commandClassNames): static
{
$this->consoleCommands = array_merge($this->consoleCommands, collect($commandClassNames)->flatten()->toArray());

return $this;
}

public function hasRoute(string $routeFileName): static
{
$this->routeFileNames[] = $routeFileName;
Expand Down
4 changes: 4 additions & 0 deletions src/PackageServiceProvider.php
Expand Up @@ -98,6 +98,10 @@ public function boot()
$this->package->basePath('/../resources/dist') => public_path("vendor/{$this->package->shortName()}"),
], "{$this->package->shortName()}-assets");
}

if (! empty($this->package->consoleCommands)) {
$this->commands($this->package->consoleCommands);
}
}

if (! empty($this->package->commands)) {
Expand Down

0 comments on commit d6c08be

Please sign in to comment.