This commit is contained in:
Marcel Pociot
2020-04-24 12:37:31 +02:00
parent 018d778e5f
commit 9ce19f975e
28 changed files with 1160 additions and 91 deletions

View File

@@ -8,7 +8,7 @@ use React\EventLoop\LoopInterface;
class ServeCommand extends Command
{
protected $signature = 'serve {host=0.0.0.0} {hostname=localhost}';
protected $signature = 'serve {host=0.0.0.0} {hostname=localhost} {--validateAuthTokens}';
protected $description = 'Start the shaft server';
@@ -18,6 +18,7 @@ class ServeCommand extends Command
->setLoop(app(LoopInterface::class))
->setHost($this->argument('host'))
->setHostname($this->argument('hostname'))
->validateAuthTokens($this->option('validateAuthTokens'))
->createServer()
->run();
}

View File

@@ -3,23 +3,37 @@
namespace App\Commands;
use App\Client\Factory;
use App\Logger\CliRequestLogger;
use Illuminate\Console\Scheduling\Schedule;
use LaravelZero\Framework\Commands\Command;
use React\EventLoop\LoopInterface;
use Symfony\Component\Console\Output\ConsoleOutput;
class ShareCommand extends Command
{
protected $signature = 'share {host} {--subdomain=} {--auth=}';
protected $signature = 'share {host} {--subdomain=} {--auth=} {--token=}';
protected $description = 'Share a local url with a remote shaft server';
protected function configureConnectionLogger()
{
app()->bind(CliRequestLogger::class, function () {
return new CliRequestLogger(new ConsoleOutput());
});
return $this;
}
public function handle()
{
$this->configureConnectionLogger();
(new Factory())
->setLoop(app(LoopInterface::class))
// ->setHost('beyond.sh') // TODO: Read from (local/global) config file
// ->setPort(8080) // TODO: Read from (local/global) config file
->setAuth($this->option('auth'))
->setAuthToken($this->option('token'))
->createClient($this->argument('host'), explode(',', $this->option('subdomain')))
->createHttpServer()
->run();

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Commands;
use Illuminate\Console\Command;
class ShareCurrentWorkingDirectoryCommand extends ShareCommand
{
protected $signature = 'share-cwd {host?} {--subdomain=} {--auth=}';
public function handle()
{
$this->input->setArgument('host', basename(getcwd()).'.test');
parent::handle();
}
}