Skip to content

Commit

Permalink
Merge pull request #9 from joshuaGlass808/DevB
Browse files Browse the repository at this point in the history
Major updates, moved src to its own repo
  • Loading branch information
joshuaGlass808 authored Jun 21, 2020
2 parents ae76e3f + d56efdc commit f1bd865
Show file tree
Hide file tree
Showing 15 changed files with 167 additions and 447 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/vendor
/app/Storage/logs/*.log
/logs/*.log
.env
14 changes: 7 additions & 7 deletions app/Commands/ExampleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace App\Commands;

use SCF\Interfaces\CmdInterface;
use SCF\Shell\BaseCmd;
use SCF\Traits\CmdTrait;
use SCF\Styles\TextColor;
use SCF\Contracts\CommandContract;
use SCF\Commands\BaseCommand;
use SCF\Traits\CommandTrait;
use SCF\Styles\TextStyle;

class ExampleCommand extends BaseCmd implements CmdInterface
class ExampleCommand extends BaseCommand implements CommandContract
{
use CmdTrait;
use CommandTrait;

public string $signature = 'print:message';
public array $argumentMap = [
Expand All @@ -30,7 +30,7 @@ public function execute(): void
$this->success("Message: {$args['message']}\n");
$this->warn("Environment: {$this->env['ENV']}\n");
$this->warn("Config DB Driver: {$this->config['database-driver']}\n");
$this->output('Execution took: ' . (microtime(true) - $start) . " seconds\n", TextColor::CYAN);
$this->output('Execution took: ' . (microtime(true) - $start) . " seconds\n", TextStyle::CYAN);
}
}
}
44 changes: 12 additions & 32 deletions app/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
namespace App;

use App\Commands\ExampleCommand;
use SCF\Contracts\KernelContract;
use SCF\Traits\KernelTrait;

use SCF\Shell\{
BaseCmd,
CreateShell
use SCF\Commands\{
BaseCommand,
CreateCommand
};

class Kernel
class Kernel implements KernelContract
{
use KernelTrait;
/**
* Register Commands here.
* Register your Commands here.
*/
const COMMANDS = [
ExampleCommand::class,
Expand All @@ -21,14 +24,14 @@ class Kernel
/**
* Classes is a method were you register all the command classes.
* They be from any namespace as long as they implement
* extend BaseCmd and have an execute method.
* extend BaseCommand and have an execute method.
*
* @return array - an array of all registered commands.
*/
public static function classes(): array
{
$commands = self::COMMANDS;
$commands[] = CreateShell::class;
$commands[] = CreateCommand::class;

return $commands;
}
Expand All @@ -38,9 +41,9 @@ public static function classes(): array
*
* @param string $signature - The command signature <basic:signature:block>
* @param null|array $args - Arguments passed with the command at run time.
* @return null|BaseCmd - Returns a Cmd class or null if not registered.
* @return null|BaseCommand - Returns a Cmd class or null if not registered.
*/
public static function getCommandClass(string $signature, ?array $args, array $env, array $config): ?BaseCmd
public static function getCommandClass(string $signature, ?array $args, array $env, array $config): ?BaseCommand
{
$classes = self::classes();
$classSignatures = [];
Expand All @@ -59,27 +62,4 @@ public static function getCommandClass(string $signature, ?array $args, array $e

return null;
}

/**
* Display Help Message.
*
* @return void
*/
public static function printHelp(): void
{
$classes = self::classes();
print "Usage: ./scf <shell:signature> [--args=...]\n"
. " ./scf -h\n\n";

rsort($classes);
foreach ($classes as $class) {
$c = new $class;
$s = ' ';
print $s . $c->signature . "\n";
foreach ($c->argumentMap as $arg => $desc) {
print $s . $s . $arg . ' : ' . $desc . "\n";
}
print "\n";
}
}
}
Empty file removed app/Storage/logs/empty
Empty file.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
],
"autoload": {
"psr-4": {
"App\\": "app/",
"SCF\\": "src/"
"App\\": "app/"
}
},
"require": {
"php": "^7.4"
"php": "^7.4",
"scf/simple-command-framework": "^1.0"
},
"prefer-stable": true,
"scripts": {
Expand Down
Loading

0 comments on commit f1bd865

Please sign in to comment.