Add SQL schema, CLI commands, and initialization logic
This commit is contained in:
parent
bc6e814c42
commit
ff1363c63f
12 changed files with 327 additions and 1 deletions
|
@ -2,6 +2,9 @@
|
|||
|
||||
namespace Socialbox;
|
||||
|
||||
use OptsLib\Parse;
|
||||
use Socialbox\Enums\CliCommands;
|
||||
|
||||
class Program
|
||||
{
|
||||
/**
|
||||
|
@ -12,7 +15,57 @@
|
|||
*/
|
||||
public static function main(array $args): int
|
||||
{
|
||||
print("Hello World from net.nosial.socialbox!" . PHP_EOL);
|
||||
// Parse the arguments into a more usable array format
|
||||
$args = Parse::parseArgument($args);
|
||||
|
||||
if(isset($args['help']))
|
||||
{
|
||||
if($args['help'] === true)
|
||||
{
|
||||
return self::displayHelp();
|
||||
}
|
||||
|
||||
$command = CliCommands::tryFrom($args['help']);
|
||||
|
||||
if($command === null)
|
||||
{
|
||||
print(sprintf("Unknown command '%s'\n", $args['help']));
|
||||
return 0;
|
||||
}
|
||||
|
||||
print($command->getHelpMessage());
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(isset($args[CliCommands::INITIALIZE->value]))
|
||||
{
|
||||
return CliCommands::INITIALIZE->handle($args);
|
||||
}
|
||||
|
||||
return self::displayHelp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the help message for the Socialbox CLI Management Interface.
|
||||
*
|
||||
* This method prints out the usage instructions and a list of available commands.
|
||||
*
|
||||
* @return int Returns 0 upon successful display of the help message.
|
||||
*/
|
||||
private static function displayHelp(): int
|
||||
{
|
||||
print("Socialbox - CLI Management Interface\n");
|
||||
print("Usage: socialbox [command] [arguments]\n\n");
|
||||
print("Commands:\n");
|
||||
print(" help - Displays this help message.\n");
|
||||
|
||||
foreach(CliCommands::cases() as $command)
|
||||
{
|
||||
print(sprintf(" %s - %s\n", $command->value, $command->getShortHelpMessage()));
|
||||
}
|
||||
|
||||
print("Use 'socialbox --help=[command]' for more information about a command.\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue