Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Commit

Permalink
WIP: Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximilian Schmidt committed Nov 1, 2018
1 parent 54b2b17 commit bcb2395
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 11 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added


- Automated app-configuration by reflecting the main class
- Simple command definition through reflection of the command handler classes
- Basic configuration annotations
- Comprehensive and dynamic Input-Output-System
- Global dependency injection container with support for autowiring and annotation-based injection
- Error and exception handlers with enduser-friendly output formatting
- Static application runner for simplified execution

<!-- ### Changed -->

Expand Down
44 changes: 39 additions & 5 deletions Classes/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ class Console extends DefaultApplicationConfig
*/
protected $docBlockFactory;

/**
* Run the application.
*
* @param ApplicationConfig|null $config Optional configuration object to use for execution.
* @return void
*/
public static function run(ApplicationConfig $config = null)
{
if ($config === null) {
Expand Down Expand Up @@ -85,6 +91,11 @@ public static function run(ApplicationConfig $config = null)
exit($code);
}

/**
* Register the internal error and exception handlers.
*
* @return void
*/
public static function registerHandlers()
{
$io = new RawIO;
Expand Down Expand Up @@ -113,7 +124,8 @@ public static function registerHandlers()
}

/**
* Get the DI-container instance.
* Get the dependency container.
*
* @return Container
*/
public static function getContainer() : Container
Expand Down Expand Up @@ -172,16 +184,32 @@ public function execute()
static::run($this);
}

/**
* Prepare the configuration with common settings.
*
* @return void
*/
protected function configure()
{
parent::configure();

$this->addOption('assume-yes', 'y', Option::NO_VALUE | Option::BOOLEAN, 'Assume yes as answer for all confirmations');
// $this->addOption('assume-no', null, Option::NO_VALUE | Option::BOOLEAN, 'Assume no as answer for all confirmations');
$this->addOption(
'assume-yes',
'y',
Option::NO_VALUE | Option::BOOLEAN,
'Assume yes as answer for all confirmations'
);

// $this->addOption(
// 'assume-no',
// null,
// Option::NO_VALUE | Option::BOOLEAN,
// 'Assume no as answer for all confirmations'
// );
}

/**
* Analyses the current inheriting class in order to recieve the configuration options automatically from code.
* Analyse the current inheriting class in order to recieve the configuration options automatically from code.
*
* @return void
* @throws \InvalidArgumentException
Expand Down Expand Up @@ -230,7 +258,7 @@ public function init()
}

/**
* Configures the application.
* Configure the application.
*
* @param array $config The application configuration
* @return void
Expand Down Expand Up @@ -280,6 +308,12 @@ public function initFromConfig(array $config)
}
}

/**
* Add a command to the configuration.
*
* @param string $class The command handler class to analyze
* @return mixed
*/
public function addCommand(string $class)
{
Assert::classExists($class, "Command handler class '%s' could not be found!");
Expand Down
2 changes: 1 addition & 1 deletion Docs/references/algorithm.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This is to prevent configuration errors of your commands since any information i
Any of the single parts throws an exception of type `MCStreetguy\SmartConsole\Exceptions\ConfigurationException` when anything goes wrong if not stated otherwise in the belonging section.

!!! tip "Developers Note"
If you prefer to understand the procedure yourself, you are welcome to have a look at the [source code](https://github.com/MCStreetguy/SmartConsole/blob/master/Classes/Console.php#L157).
If you prefer to understand the procedure yourself, you are welcome to have a look at the [source code](https://github.com/mcstreetguy/smartconsole/blob/master/Classes/Utility/Analyzer.php#L61).

## Procedure

Expand Down
8 changes: 5 additions & 3 deletions Docs/references/annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ The following annotations apply to the configuration class instance only.

### [`App\Version`](https://github.com/MCStreetguy/SmartConsole/blob/master/Classes/Annotations/Application/Version.php)

Sets the application version.
Sets the application version string.

### [`App\DebugMode`](https://github.com/MCStreetguy/SmartConsole/blob/master/Classes/Annotations/Application/DebugMode.php)

Sets the application in debug-mode.
Run the application in debug-mode.
This results in more detailled error output including stack traces and some more debugging-related features.

### [`App\DisplayName`](https://github.com/MCStreetguy/SmartConsole/blob/master/Classes/Annotations/Application/DisplayName.php)

Sets the readable form of the application name.
Sets the readable form of the application name.
This gets used on the help page for example.
8 changes: 7 additions & 1 deletion Docs/references/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added


- Automated app-configuration by reflecting the main class
- Simple command definition through reflection of the command handler classes
- Basic configuration annotations
- Comprehensive and dynamic Input-Output-System
- Global dependency injection container with support for autowiring and annotation-based injection
- Error and exception handlers with enduser-friendly output formatting
- Static application runner for simplified execution

<!-- ### Changed -->

Expand Down

0 comments on commit bcb2395

Please sign in to comment.