|
1 | 1 | <?php |
2 | 2 | require __DIR__ . '/../vendor/autoload.php'; |
3 | 3 |
|
4 | | -$cli = new WizardCLI\WizardCLI(['theme' => 'gold']); |
5 | | -$cli->table(["Wizard", "Power"], [ |
6 | | - ["Gandalf", "Lightning"], |
7 | | - ["Harry", "Expelliarmus"] |
| 4 | +// Available themes: wizard, sorcerer, dark, gold, emerald (custom) |
| 5 | +$themes = [ |
| 6 | + "wizard" => ['primary' => 'magenta', 'accent' => 'cyan', 'banner' => 'yellow+bold'], |
| 7 | + "sorcerer" => ['primary' => 'blue', 'accent' => 'white', 'banner' => 'blue+bold'], |
| 8 | + "dark" => ['primary' => 'gray', 'accent' => 'magenta', 'banner' => 'gray+bold'], |
| 9 | + "gold" => ['primary' => 'yellow', 'accent' => 'white', 'banner' => 'yellow+bold'], |
| 10 | + "emerald" => ['primary' => 'green', 'accent' => 'yellow', 'banner' => 'green+bold'], |
| 11 | +]; |
| 12 | + |
| 13 | +// To add a theme: patch src/WizardCLI.php and src/Colors.php as needed. |
| 14 | +// For demo, we'll just change accent for the demo object: |
| 15 | + |
| 16 | +foreach (['wizard', 'sorcerer', 'dark', 'gold'] as $theme) { |
| 17 | + $cli = new WizardCLI\WizardCLI(['theme' => $theme]); |
| 18 | + $cli->color("======== Theme: " . ucfirst($theme) . " ========", "magenta+bold"); |
| 19 | + |
| 20 | + // 1. Basic Table Example |
| 21 | + $cli->color("🧙 Basic Table Example:", "cyan+bold"); |
| 22 | + $cli->table(["Name", "Spell"], [ |
| 23 | + ["Merlin", "Invisibility"], |
| 24 | + ["Morgana", "Fireball"] |
| 25 | + ]); |
| 26 | + echo PHP_EOL; |
| 27 | + |
| 28 | + // 2. Extended Table Example |
| 29 | + $cli->color("🪄 Extended Wizard Table:", "magenta+bold"); |
| 30 | + $cli->table(["Name", "Class", "Power", "Realm"], [ |
| 31 | + ["Gandalf", "White", "Lightning Strike", "Middle-earth"], |
| 32 | + ["Dumbledore", "Headmaster", "Phoenix Flame", "Hogwarts"], |
| 33 | + ["Saruman", "Grey", "Mind Control", "Isengard"] |
| 34 | + ]); |
| 35 | + echo PHP_EOL; |
| 36 | +} |
| 37 | + |
| 38 | +// Example for a custom theme (emerald) — you must define it in WizardCLI class to use this properly! |
| 39 | +$cli = new WizardCLI\WizardCLI(['theme' => 'wizard']); // fallback if 'emerald' theme not implemented |
| 40 | +if (in_array('emerald', array_keys($themes))) { |
| 41 | + $cli = new WizardCLI\WizardCLI(['theme' => 'emerald']); |
| 42 | + $cli->color("======== Theme: Emerald (Custom) ========", "green+bold"); |
| 43 | +} |
| 44 | + |
| 45 | +// 3. Table With Special Characters & Unicode |
| 46 | +$cli->color("✨ Table with Special Characters:", "yellow+bold"); |
| 47 | +$cli->table(["Wizard", "Item", "Emoji"], [ |
| 48 | + ["Rincewind", "Luggage", "🧳"], |
| 49 | + ["Hermione", "Time-Turner", "⏳"], |
| 50 | + ["Elminster", "Staff", "🪄"] |
| 51 | +]); |
| 52 | +echo PHP_EOL; |
| 53 | + |
| 54 | +// 4. Table With Long Text / Wrapping |
| 55 | +$cli->color("📖 Table with Long Text:", "blue+bold"); |
| 56 | +$cli->table(["Wizard", "Spell Description"], [ |
| 57 | + ["Prospero", "Controls the elements of wind and sea, can summon storms and command spirits."], |
| 58 | + ["Medea", "Expert in potions, transformations, and ancient Greek magic rituals."], |
| 59 | +]); |
| 60 | +echo PHP_EOL; |
| 61 | + |
| 62 | +// 5. Table With Empty Cells / Null Values |
| 63 | +$cli->color("🕳️ Table with Empty Cells:", "gray+bold"); |
| 64 | +$cli->table(["Wizard", "Familiar", "Specialty"], [ |
| 65 | + ["Merlin", "Owl", "Prophecy"], |
| 66 | + ["Morgana", "", "Dark Magic"], |
| 67 | + ["Alatar", "Horse", ""], |
| 68 | + ["Radagast", null, "Beasts"] |
| 69 | +]); |
| 70 | +echo PHP_EOL; |
| 71 | + |
| 72 | +// 6. Multilingual Table (Unicode) |
| 73 | +$cli->color("🌍 Multilingual Table Example:", "green+bold"); |
| 74 | +$cli->table(["Wizard", "Country", "Symbol"], [ |
| 75 | + ["Magician", "Israel", "✨"], |
| 76 | + ["Sorcière", "France", "🔮"], |
| 77 | + ["Wizard", "England", "🦉"], |
| 78 | + ["Волшебник", "Russia", "🧙♂️"] |
| 79 | +]); |
| 80 | +echo PHP_EOL; |
| 81 | + |
| 82 | +// 7. Table With Numbers & Alignment |
| 83 | +$cli->color("🔢 Table with Numbers:", "red+bold"); |
| 84 | +$cli->table(["Rank", "Wizard", "Points"], [ |
| 85 | + [1, "Merlin", "1200"], |
| 86 | + [2, "Morgana", "1150"], |
| 87 | + [3, "Gandalf", "1100"], |
| 88 | + [4, "Saruman", "950"], |
8 | 89 | ]); |
0 commit comments