diff --git a/.gitattributes b/.gitattributes
index 455116e..807a737 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,5 +1,6 @@
* text=auto
+/.art export-ignore
/.github export-ignore
/tests export-ignore
.editorconfig export-ignore
diff --git a/README.md b/README.md
index adeb38c..da483df 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,8 @@
-# Minicli Framework
+
+
+
+
Minicli Framework
+
+
This repo contains the source code for the Minicli Framework - a great way to extend the core minicli application.
diff --git a/art/minicli.png b/art/minicli.png
new file mode 100644
index 0000000..061201c
Binary files /dev/null and b/art/minicli.png differ
diff --git a/src/Configuration/Config.php b/src/Configuration/Config.php
new file mode 100644
index 0000000..1ef2494
--- /dev/null
+++ b/src/Configuration/Config.php
@@ -0,0 +1,47 @@
+|null $theme
+ * @param bool $debug
+ */
+ public function __construct(
+ private readonly string $path,
+ private readonly ?string $theme = null,
+ private readonly bool $debug = false,
+ ) {
+ }
+
+ /**
+ * @return array{path:string,theme:class-string|null,debug:bool}
+ */
+ public function toArray(): array
+ {
+ return [
+ 'path' => $this->path,
+ 'theme' => $this->theme,
+ 'debug' => $this->debug,
+ ];
+ }
+
+ /**
+ * @param array{path:string,theme:class-string|null,debug:bool|null} $data
+ * @return Config
+ */
+ public static function make(array $data): Config
+ {
+ return new Config(
+ path: $data['path'],
+ theme: $data['theme'],
+ debug: $data['debug'] ?? false,
+ );
+ }
+}
diff --git a/src/Contracts/Theme/ThemeContract.php b/src/Contracts/Theme/ThemeContract.php
index 651bf01..ad2b7c1 100644
--- a/src/Contracts/Theme/ThemeContract.php
+++ b/src/Contracts/Theme/ThemeContract.php
@@ -4,53 +4,38 @@
namespace Minicli\Framework\Contracts\Theme;
+namespace Minicli\Framework\Contracts\Theme;
+namespace Minicli\Framework\Theme;
+
interface ThemeContract
{
- /**
- * Default style
- * @return array
- */
- public function default(): array;
-
- /**
- * Alternative style for Default
- * @return array
- */
- public function alt(): array;
-
- /**
- * Error style
- * @return array
- */
- public function error(): array;
-
- /**
- * Alternative style for Error
- * @return array
- */
- public function errorAlt(): array;
-
- /**
- * Success style
- * @return array
- */
- public function success(): array;
-
- /**
- * Alternative style for Success
- * @return array
- */
- public function successAlt(): array;
-
- /**
- * Info style
- * @return array
- */
- public function info(): array;
-
- /**
- * Alternative style for Info
- * @return array
- */
- public function infoAlt(): array;
+ public function default(): ThemeStyle;
+
+ public function alt(): ThemeStyle;
+
+ public function error(): ThemeStyle;
+
+ public function errorAlt(): ThemeStyle;
+
+ public function warning(): ThemeStyle;
+
+ public function warningAlt(): ThemeStyle;
+
+ public function success(): ThemeStyle;
+
+ public function successAlt(): ThemeStyle;
+
+ public function info(): ThemeStyle;
+
+ public function infoAlt(): ThemeStyle;
+
+ public function bold(): ThemeStyle;
+
+ public function dim(): ThemeStyle;
+
+ public function italic(): ThemeStyle;
+
+ public function underline(): ThemeStyle;
+
+ public function invert(): ThemeStyle;
}
diff --git a/src/Minicli.php b/src/Minicli.php
index 906f35d..3ced2cc 100644
--- a/src/Minicli.php
+++ b/src/Minicli.php
@@ -4,113 +4,43 @@
namespace Minicli\Framework;
-use Minicli\Framework\Commands\PendingCommand;
+use Minicli\Framework\Configuration\Config;
use Minicli\Framework\Contracts\Output\PrinterContract;
use Minicli\Framework\Contracts\Theme\ThemeContract;
use Minicli\Framework\DI\Container;
-use Minicli\Framework\Exceptions\BindingResolutionException;
use Minicli\Framework\Output\Engine;
use Minicli\Framework\Output\Printer\DefaultPrinter;
use Minicli\Framework\Theme\Catalog\DefaultTheme;
-use ReflectionException;
final class Minicli extends Container
{
public const VERSION = '0.0.1';
- public string $name;
-
- public array|string $path;
-
- public ThemeContract $theme;
-
- public bool $debug = false;
-
- public Engine $engine;
+ public function __construct(
+ protected readonly Config $config,
+ ) {
+ parent::__construct();
+ }
/**
- * @param string $name
- * @param array|string $path
- * @param null|class-string $theme
+ * @param string $path
+ * @param class-string|null $theme
* @param bool $debug
- * @param PrinterContract|null $printer
* @return Minicli
*/
public static function boot(
- string $name,
- array|string $path,
- null|string $theme,
+ string $path,
+ ?string $theme,
bool $debug = false,
- null|PrinterContract $printer = null,
): Minicli {
- return Minicli::getInstance()->name(
- name: $name,
- )->path(
+ $config = new Config(
path: $path,
- )->theme(
- theme: $theme ?? DefaultTheme::class,
- )->debug(
+ theme: $theme,
debug: $debug,
- )->buildEngine(
- printer: $printer ?? new DefaultPrinter(),
- );
- }
-
- public function name(string $name): Minicli
- {
- $this->name = $name;
-
- return $this;
- }
-
- public function path(string|array $path): Minicli
- {
- $this->path = $path;
-
- return $this;
- }
-
- /**
- * @param class-string $theme
- * @return $this
- * @throws BindingResolutionException|ReflectionException
- */
- public function theme(string $theme): Minicli
- {
- /**
- * @var ThemeContract $instance
- */
- $instance = $this->make(
- abstract: $theme,
);
- $this->theme = $instance;
-
- return $this;
- }
-
- public function debug(bool $debug): Minicli
- {
- $this->debug = $debug;
-
- return $this;
- }
-
- public function buildEngine(PrinterContract $printer): Minicli
- {
- $this->engine = new Engine(
- theme: $this->theme,
- printer: $printer,
- );
-
- return $this;
- }
-
- public function run(array $arguments = []): void
- {
- $command = PendingCommand::build(
- arguments: $arguments,
+ return new Minicli(
+ config: $config
);
- // build and send command through engine.
}
}
diff --git a/src/Theme/Catalog/DefaultTheme.php b/src/Theme/Catalog/DefaultTheme.php
index 6c53e4c..678d2d2 100644
--- a/src/Theme/Catalog/DefaultTheme.php
+++ b/src/Theme/Catalog/DefaultTheme.php
@@ -5,68 +5,85 @@
namespace Minicli\Framework\Theme\Catalog;
use Minicli\Framework\Theme\Enums\Background;
+use Minicli\Framework\Theme\Enums\FontWeight;
use Minicli\Framework\Theme\Enums\Foreground;
use Minicli\Framework\Contracts\Theme\ThemeContract;
+use Minicli\Framework\Theme\ThemeStyle;
final class DefaultTheme implements ThemeContract
{
- public function default(): array
+ public function default(): ThemeStyle
{
- return [
- Foreground::WHITE,
- ];
+ return ThemeStyle::make(Foreground::WHITE);
}
- public function alt(): array
+ public function alt(): ThemeStyle
{
- return [
- Foreground::BLACK,
- Background::WHITE,
- ];
+ return ThemeStyle::make(Foreground::BLACK, Background::WHITE);
}
- public function error(): array
+ public function error(): ThemeStyle
{
- return [
- Foreground::RED,
- ];
+ return ThemeStyle::make(Foreground::RED);
}
- public function errorAlt(): array
+ public function errorAlt(): ThemeStyle
{
- return [
- Foreground::WHITE,
- Background::RED,
- ];
+ return ThemeStyle::make(Foreground::WHITE, Background::RED);
}
- public function success(): array
+ public function warning(): ThemeStyle
{
- return [
- Foreground::GREEN,
- ];
+ return ThemeStyle::make(Foreground::YELLOW);
}
- public function successAlt(): array
+ public function warningAlt(): ThemeStyle
{
- return [
- Foreground::WHITE,
- Background::GREEN,
- ];
+ return ThemeStyle::make(Foreground::WHITE, Background::YELLOW);
}
- public function info(): array
+ public function success(): ThemeStyle
{
- return [
- Foreground::CYAN,
- ];
+ return ThemeStyle::make(Foreground::GREEN);
}
- public function infoAlt(): array
+ public function successAlt(): ThemeStyle
{
- return [
- Foreground::WHITE,
- Background::CYAN,
- ];
+ return ThemeStyle::make(Foreground::WHITE, Background::GREEN);
+ }
+
+ public function info(): ThemeStyle
+ {
+ return ThemeStyle::make(Foreground::CYAN);
+ }
+
+ public function infoAlt(): ThemeStyle
+ {
+ return ThemeStyle::make(Foreground::WHITE, Background::CYAN);
+ }
+
+ public function bold(): ThemeStyle
+ {
+ return ThemeStyle::make(FontWeight::BOLD);
+ }
+
+ public function dim(): ThemeStyle
+ {
+ return ThemeStyle::make(FontWeight::DIM);
+ }
+
+ public function italic(): ThemeStyle
+ {
+ return ThemeStyle::make(FontWeight::ITALIC);
+ }
+
+ public function underline(): ThemeStyle
+ {
+ return ThemeStyle::make(FontWeight::UNDERLINE);
+ }
+
+ public function invert(): ThemeStyle
+ {
+ return ThemeStyle::make(FontWeight::INVERT);
}
}
diff --git a/src/Theme/ThemeStyle.php b/src/Theme/ThemeStyle.php
new file mode 100644
index 0000000..e5db925
--- /dev/null
+++ b/src/Theme/ThemeStyle.php
@@ -0,0 +1,23 @@
+