Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
lotfio committed Jul 25, 2020
2 parents b1359ad + ef07b25 commit 548bf6a
Show file tree
Hide file tree
Showing 29 changed files with 100 additions and 51 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.6.1
- fix help
- update readme

# 1.6.0
- fix call command
- better help function
Expand Down
54 changes: 51 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
## 🔥 Introduction :
Conso is a simple, lightweight PHP package that helps you create command line applications easily.

![conso](https://user-images.githubusercontent.com/18489496/87862253-622d7600-c94e-11ea-8aef-1a79a70e8ff6.gif)
![conso](https://user-images.githubusercontent.com/18489496/88460262-44ef2f00-ce9b-11ea-8b7a-18f385c0a3f3.gif)

## 📌 Requirements :
- PHP >= 7.2 or newer versions
Expand Down Expand Up @@ -241,7 +241,7 @@ class Test extends Command implements CommandInterface
* @param OutputInterface $output
* @return void
*/
public function execute(InputInterface $input, OutputInterface $output, Conso $app) : void
public function execute(InputInterface $input, OutputInterface $output) : void
{
commandHelp($this->app->invokedCommand, $output);
}
Expand All @@ -267,11 +267,59 @@ $conso->setVersion(); // set application version
$conso->setAuthor(); // set application author

```
## :star: accessing app from commands :
- from a callback command

```php
<?php

// test command
$conso->command("test", function($input, $output){

// get app config
$this->getName();
$this->getVersion();
$this->getAuthor();
$this->getCommandsPath();
$this->getCommandsNamespace();

// calling another command
$this->call('command:subcommand -f --flags');
});

```
- from a class command

```php
<?php

/**
* execute method
*
* @param InputInterface $input
* @param OutputInterface $output
* @return void
*/
public function execute(InputInterface $input, OutputInterface $output) : void
{
// get app config
$this->app->getName();
$this->app->getVersion();
$this->app->getAuthor();
$this->app->getCommandsPath();
$this->app->getCommandsNamespace();

// calling another command
$this->app->call('command:subcommand -f --flags');
}

```


## ✨ TODO
- improve code quality.
- add testing helpers.
- add compile command.
- add compile command (compile your app to an executable .phar).

## ✨ Contributing

Expand Down
2 changes: 1 addition & 1 deletion commands.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @author <[email protected]>
*
* @version 1.6.0
* @version 1.6.1
*
* @license MIT
*
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lotfio/conso",
"description": "console applications for geeks",
"description": "console applications for cool kids",
"authors": [
{
"name": "lotfio",
Expand Down
2 changes: 1 addition & 1 deletion conso
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* @author <[email protected]>
* @package Conso PHP Console Creator
* @version 1.6.0
* @version 1.6.1
* @license MIT
* @category CLI
* @copyright 2019 Lotfio Lakehal
Expand Down
2 changes: 1 addition & 1 deletion src/Conso/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @author <[email protected]>
*
* @version 1.6.0
* @version 1.6.1
*
* @license MIT
*
Expand Down
39 changes: 18 additions & 21 deletions src/Conso/CommandInvoker.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @author <[email protected]>
*
* @version 1.6.0
* @version 1.6.1
*
* @license MIT
*
Expand Down Expand Up @@ -67,30 +67,27 @@ public function __construct(InputInterface $input, OutputInterface $output, Cons
*/
public function showConsoleInformation(array $commands)
{
$this->output->writeLn($this->app->getSignature()."\n");
$this->output->writeLn($this->app->getName().' ', 'yellow');
$this->output->writeLn('version ');
$this->output->writeLn($this->app->getVersion(), 'green');
$this->output->writeLn(' by '.$this->app->getAuthor());
$output = $this->output;
$app = $this->app;

$this->output->writeLn("\n\nUsage: \n\n", 'yellow');
$this->output->writeLn(" command:subcommand [options] [flags]\n\n");
$output->writeLn($app->getSignature()."\n");
$output->writeLn($app->getName().' ', 'yellow');
$output->writeLn('version ');
$output->writeLn($app->getVersion(), 'green');
$output->writeLn(' by '.$app->getAuthor());

$this->output->writeLn("Special flags: \n\n", 'yellow');
$output->writeLn("\n\nUsage: \n\n", 'yellow');
$output->writeLn(" command:subcommand [options] [flags]\n\n");

$output->writeLn("Special flags: \n\n", 'yellow');

$flags = $this->input->reservedFlags();
$this->output->writeLn(' '.$flags[0].' ', 'green');
$this->output->writeLn(' '.$flags[1]." \n", 'green');
$this->output->writeLn(' '.$flags[2].' ', 'green');
$this->output->writeLn(' '.$flags[3]." \n", 'green');
$this->output->writeLn(' '.$flags[4].' ', 'green');
$this->output->writeLn(' '.$flags[5]." \n", 'green');
$this->output->writeLn(' '.$flags[6].' ', 'green');
$this->output->writeLn(' '.$flags[7]." \n", 'green');
$this->output->writeLn(' '.$flags[8].' ', 'green');
$this->output->writeLn($flags[9]." \n", 'green');
$this->output->writeLn(' '.$flags[10].' ', 'green');
$this->output->writeLn(' '.$flags[11]." \n", 'green');

for($i = 0; $i < count($flags); $i++)
{ // 6 = --ansi length
$line = ' ' . $flags[$i] . str_repeat(' ', (6 - strlen($flags[$i])) + 3) . $flags[++$i] . "\n";
$output->writeLn($line, 'green');
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Conso/CommandLinker.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @author <[email protected]>
*
* @version 1.6.0
* @version 1.6.1
*
* @license MIT
*
Expand Down
2 changes: 1 addition & 1 deletion src/Conso/Commands/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @author <[email protected]>
*
* @version 1.6.0
* @version 1.6.1
*
* @license MIT
*
Expand Down
2 changes: 1 addition & 1 deletion src/Conso/Commands/stubs/command
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @author <[email protected]>
* @package Conso PHP Console Creator
* @version 1.6.0
* @version 1.6.1
* @license MIT
* @category CLI
* @copyright 2019 Lotfio Lakehal
Expand Down
2 changes: 1 addition & 1 deletion src/Conso/CommandsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @author <[email protected]>
*
* @version 1.6.0
* @version 1.6.1
*
* @license MIT
*
Expand Down
2 changes: 1 addition & 1 deletion src/Conso/Conso.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @author <[email protected]>
*
* @version 1.6.0
* @version 1.6.1
*
* @license MIT
*
Expand Down
4 changes: 2 additions & 2 deletions src/Conso/ConsoTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @author <[email protected]>
*
* @version 1.6.0
* @version 1.6.1
*
* @license MIT
*
Expand Down Expand Up @@ -40,7 +40,7 @@ trait ConsoTrait
*
* @var string
*/
protected $version = '1.0.0';
protected $version = '1.6.1';

/**
* author.
Expand Down
2 changes: 1 addition & 1 deletion src/Conso/Contracts/CommandInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @author <[email protected]>
*
* @version 1.6.0
* @version 1.6.1
*
* @license MIT
*
Expand Down
2 changes: 1 addition & 1 deletion src/Conso/Contracts/InputInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @author <[email protected]>
*
* @version 1.6.0
* @version 1.6.1
*
* @license MIT
*
Expand Down
2 changes: 1 addition & 1 deletion src/Conso/Contracts/OutputInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @author <[email protected]>
*
* @version 1.6.0
* @version 1.6.1
*
* @license MIT
*
Expand Down
2 changes: 1 addition & 1 deletion src/Conso/Exceptions/InputException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @author <[email protected]>
*
* @version 1.6.0
* @version 1.6.1
*
* @license MIT
*
Expand Down
2 changes: 1 addition & 1 deletion src/Conso/Exceptions/InvokerException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @author <[email protected]>
*
* @version 1.6.0
* @version 1.6.1
*
* @license MIT
*
Expand Down
2 changes: 1 addition & 1 deletion src/Conso/Exceptions/OutputException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @author <[email protected]>
*
* @version 1.6.0
* @version 1.6.1
*
* @license MIT
*
Expand Down
2 changes: 1 addition & 1 deletion src/Conso/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @author <[email protected]>
*
* @version 1.6.0
* @version 1.6.1
*
* @license MIT
*
Expand Down
2 changes: 1 addition & 1 deletion src/Conso/Output.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @author <[email protected]>
*
* @version 1.6.0
* @version 1.6.1
*
* @license MIT
*
Expand Down
2 changes: 1 addition & 1 deletion src/Conso/hlprs.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @author <[email protected]>
*
* @version 1.6.0
* @version 1.6.1
*
* @license MIT
*
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/CommandInvokerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @author <[email protected]>
*
* @version 1.6.0
* @version 1.6.1
*
* @license MIT
*
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/CommandLinkerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @author <[email protected]>
*
* @version 1.6.0
* @version 1.6.1
*
* @license MIT
*
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/CommandsTableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @author <[email protected]>
*
* @version 1.6.0
* @version 1.6.1
*
* @license MIT
*
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/ConsoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @author <[email protected]>
*
* @version 1.6.0
* @version 1.6.1
*
* @license MIT
*
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/InputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @author <[email protected]>
*
* @version 1.6.0
* @version 1.6.1
*
* @license MIT
*
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Mocks/Make.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @author <[email protected]>
*
* @version 1.6.0
* @version 1.6.1
*
* @license MIT
*
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/OutputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @author <[email protected]>
*
* @version 1.6.0
* @version 1.6.1
*
* @license MIT
*
Expand Down

0 comments on commit 548bf6a

Please sign in to comment.