- Move 12 markdown files from root to docs/ subdirectories - Organize documentation by category: • docs/troubleshooting/ (1 file) - Technical troubleshooting guides • docs/deployment/ (4 files) - Deployment and security documentation • docs/guides/ (3 files) - Feature-specific guides • docs/planning/ (4 files) - Planning and improvement proposals Root directory cleanup: - Reduced from 16 to 4 markdown files in root - Only essential project files remain: • CLAUDE.md (AI instructions) • README.md (Main project readme) • CLEANUP_PLAN.md (Current cleanup plan) • SRC_STRUCTURE_IMPROVEMENTS.md (Structure improvements) This improves: ✅ Documentation discoverability ✅ Logical organization by purpose ✅ Clean root directory ✅ Better maintainability
186 lines
6.3 KiB
PHP
186 lines
6.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Framework\Console\DemoCommand;
|
|
|
|
use App\Framework\Console\ConsoleCommand;
|
|
use App\Framework\Console\ConsoleInput;
|
|
use App\Framework\Console\ConsoleOutput;
|
|
use App\Framework\Console\ConsoleStyle;
|
|
use App\Framework\Console\ExitCode;
|
|
use App\Framework\Console\Screen\ScreenType;
|
|
use App\Framework\Core\ValueObjects\Duration;
|
|
use App\Framework\DateTime\Timer;
|
|
|
|
final class ScreenDemoCommand
|
|
{
|
|
public function __construct(
|
|
private readonly Timer $timer
|
|
) {
|
|
}
|
|
|
|
#[ConsoleCommand('demo:screen', 'Zeigt die verschiedenen Screen-Management-Funktionen')]
|
|
public function __invoke(ConsoleInput $input, ConsoleOutput $output): ExitCode
|
|
{
|
|
// Aktiviere interaktiven Modus
|
|
$output->screen->setInteractiveMode(true);
|
|
|
|
// Zeige ein Menü
|
|
$output->screen->newMenu();
|
|
$output->writeLine('=== Screen-Management Demo ===', ConsoleStyle::success());
|
|
$output->writeLine('');
|
|
$output->writeLine('1. Cursor-Bewegungen');
|
|
$output->writeLine('2. Bildschirmlöschung');
|
|
$output->writeLine('3. Fortschrittsanzeige');
|
|
$output->writeLine('4. Typensatz-Beispiel');
|
|
$output->writeLine('');
|
|
|
|
$choice = $output->askQuestion('Wählen Sie eine Option (1-4)');
|
|
|
|
switch ($choice) {
|
|
case '1':
|
|
$this->demoCursor($input, $output);
|
|
|
|
break;
|
|
case '2':
|
|
$this->demoDisplay($input, $output);
|
|
|
|
break;
|
|
case '3':
|
|
$this->demoProgress($input, $output);
|
|
|
|
break;
|
|
case '4':
|
|
$this->demoTypeset($input, $output);
|
|
|
|
break;
|
|
default:
|
|
$output->writeError('Ungültige Auswahl!');
|
|
}
|
|
|
|
return ExitCode::SUCCESS;
|
|
}
|
|
|
|
private function demoCursor(ConsoleInput $input, ConsoleOutput $output): void
|
|
{
|
|
$output->screen->new(ScreenType::CONTENT);
|
|
$output->writeLine('=== Cursor-Bewegungs-Demo ===', ConsoleStyle::success());
|
|
$output->writeLine('');
|
|
|
|
// Cursor-Bewegungen
|
|
$output->writeLine('Der Cursor wird jetzt bewegt...');
|
|
$this->timer->sleep(Duration::fromSeconds(1));
|
|
|
|
$output->cursor->down(2)->right(5);
|
|
$output->write('Hallo!', ConsoleStyle::success());
|
|
$this->timer->sleep(Duration::fromSeconds(1));
|
|
|
|
$output->cursor->down(1)->left(5);
|
|
$output->write('Welt!', ConsoleStyle::info());
|
|
$this->timer->sleep(Duration::fromSeconds(1));
|
|
|
|
$output->cursor->moveTo(10, 20);
|
|
$output->write('Position 10,20', ConsoleStyle::warning());
|
|
$this->timer->sleep(Duration::fromSeconds(1));
|
|
|
|
$output->cursor->home();
|
|
$output->writeLine("\nZurück zum Anfang!", ConsoleStyle::error());
|
|
$this->timer->sleep(Duration::fromSeconds(1));
|
|
|
|
$output->writeLine("\nDrücken Sie eine Taste, um fortzufahren...");
|
|
$output->screen->waitForInput();
|
|
}
|
|
|
|
private function demoDisplay(ConsoleInput $input, ConsoleOutput $output): void
|
|
{
|
|
$output->screen->new(ScreenType::CONTENT);
|
|
$output->writeLine('=== Bildschirmlöschungs-Demo ===', ConsoleStyle::success());
|
|
$output->writeLine('');
|
|
|
|
// Bildschirm füllen
|
|
for ($i = 1; $i <= 10; $i++) {
|
|
$output->writeLine("Zeile $i: Dies ist ein Test");
|
|
}
|
|
|
|
$this->timer->sleep(Duration::fromSeconds(1));
|
|
$output->writeLine("\nLösche in 3 Sekunden den Bildschirm...");
|
|
$this->timer->sleep(Duration::fromSeconds(3));
|
|
|
|
// Bildschirm löschen
|
|
$output->display->clear();
|
|
$output->writeLine('Bildschirm wurde gelöscht!');
|
|
$this->timer->sleep(Duration::fromSeconds(1));
|
|
|
|
// Zeilen hinzufügen
|
|
for ($i = 1; $i <= 5; $i++) {
|
|
$output->writeLine("Neue Zeile $i");
|
|
}
|
|
|
|
$this->timer->sleep(Duration::fromSeconds(1));
|
|
$output->writeLine("\nLösche nur die aktuelle Zeile in 2 Sekunden...");
|
|
$this->timer->sleep(Duration::fromSeconds(2));
|
|
|
|
// Zeile löschen
|
|
$output->display->clearLine();
|
|
$output->writeLine('Die Zeile wurde gelöscht und durch diese ersetzt!');
|
|
|
|
$this->timer->sleep(Duration::fromSeconds(1));
|
|
$output->writeLine("\nDrücken Sie eine Taste, um fortzufahren...");
|
|
$output->screen->waitForInput();
|
|
}
|
|
|
|
private function demoProgress(ConsoleInput $input, ConsoleOutput $output): void
|
|
{
|
|
$output->screen->new(ScreenType::PROGRESS);
|
|
$output->writeLine('=== Fortschrittsanzeige-Demo ===', ConsoleStyle::success());
|
|
$output->writeLine('');
|
|
|
|
$total = 20;
|
|
|
|
for ($i = 0; $i <= $total; $i++) {
|
|
$percent = floor(($i / $total) * 100);
|
|
$bar = str_repeat('█', $i) . str_repeat('░', $total - $i);
|
|
|
|
// Zeile löschen und neue Fortschrittsanzeige
|
|
$output->display->clearLine();
|
|
$output->write("Fortschritt: [{$bar}] {$percent}%");
|
|
|
|
$this->timer->sleep(Duration::fromMilliseconds(200));
|
|
}
|
|
|
|
$output->writeLine("\n\nFortschritt abgeschlossen!");
|
|
$this->timer->sleep(Duration::fromSeconds(1));
|
|
|
|
$output->writeLine("\nDrücken Sie eine Taste, um fortzufahren...");
|
|
$output->screen->waitForInput();
|
|
}
|
|
|
|
private function demoTypeset(ConsoleInput $input, ConsoleOutput $output): void
|
|
{
|
|
$output->screen->new(ScreenType::CONTENT);
|
|
$output->writeLine('=== Typensatz-Demo ===', ConsoleStyle::success());
|
|
$output->writeLine('');
|
|
|
|
$text = 'Dies ist eine Demonstration des Typensatz-Effekts. Der Text wird Zeichen für Zeichen angezeigt, ' .
|
|
'als ob er gerade getippt würde. Diese Technik kann für Intros, Tutorials oder ' .
|
|
'dramatische Effekte verwendet werden.';
|
|
|
|
// Typensatz-Effekt
|
|
foreach (str_split($text) as $char) {
|
|
$output->write($char);
|
|
$this->timer->sleep(Duration::fromMicroseconds(rand(50000, 150000)));
|
|
}
|
|
|
|
$output->writeLine("\n\nTypensatz abgeschlossen!");
|
|
$this->timer->sleep(Duration::fromSeconds(1));
|
|
|
|
$output->writeLine("\nDrücken Sie eine Taste, um zurückzukehren...");
|
|
$output->screen->waitForInput();
|
|
|
|
// Zurück zum Hauptmenü
|
|
$output->screen->newMenu();
|
|
$this->__invoke($input, $output);
|
|
}
|
|
}
|