- Still WIP on storage and a new Update function also started

This commit is contained in:
mcndave committed 2023-03-22 19:09:37 -04:00
1 parent 689120dd44
commit bf1bec644b
8 files changed
+112 -11

No files matched your search

+12 -1
View File
@@ -2,11 +2,12 @@
namespace Lean\Console\Controller;
use Picea\Ui\Method\FormHandler;
use Psr\Http\Message\{ ResponseInterface, ServerRequestInterface };
use Notes\Tell\Attribute\Language, Notes\Route\Attribute\Method\Route;
use \Lean\Console\Lib;
use \Lean\Console\{ Lib, Form };
#[Language("lean.console")]
class Console {
@@ -19,4 +20,14 @@ class Console {
]);
}
#[Route(route: "/update", name: "lean.console:update")]
public function update(ServerRequestInterface $request, array $arguments) : ResponseInterface
{
new FormHandler($request, $git = new Form\Update\Git(getenv('PROJECT_PATH')));
$status = iterator_to_array($git->run("/usr/bin/git status -s"));
return $this->renderView("lean-console/page/update/index", get_defined_vars());
}
}
+49
View File
@@ -0,0 +1,49 @@
<?php
namespace Lean\Console\Form\Update;
use Picea\Ui\Method\{ FormInterface, FormContext, FormContextInterface };
use \Lean\Console\{ Lib, Entity };
use Picea\Compiler\Context;
use Psr\Http\Message\ServerRequestInterface;
use Ulmus\{ EntityCollection };
class Git implements FormInterface
{
public function __construct(
public string $projectPath = "",
)
{
}
public function initialize(FormContextInterface $context) : void
{
}
public function validate(FormContextInterface $context) : bool
{
return $context->valid();
}
public function execute(FormContextInterface $context) : void
{
}
public function run(string $command) : \Generator
{
$command = escapeshellcmd($command);
$handle = popen("$command", 'r');
while ( false !== $output = fgets($handle, 2096) ){
yield trim($output);
}
pclose($handle);
}
}