Skip to content

Commit

Permalink
adding a way to pass arguments, and a alternative autoload php file
Browse files Browse the repository at this point in the history
  • Loading branch information
reisraff committed Jun 29, 2018
1 parent da776c1 commit 1310707
Show file tree
Hide file tree
Showing 7 changed files with 328 additions and 107 deletions.
45 changes: 39 additions & 6 deletions DOCUMENTATION.md
Expand Up @@ -8,9 +8,20 @@ the ones matching the following pattern `[P,p]hulp[Ff]il{e,e.php}` nevertheless
```php
<?php

// filepath: /path/for/your/phulpfile.php

use Phulp\Output as out;

// Define the default task
$phulp->task('default', function ($phulp) {
out::out(out::colorize('Arguments:', 'green'));
out::out(print_r($phulp->getArguments(), true));

$phulp->start(['clean', 'iterate_src_folder', 'sync_command', 'async_command']);
if ($phulp->getArgument('repeat-clean', false)) {
out::out(out::colorize('Repeating "clean":', 'green'));
$phulp->start(['clean']);
}
});

// Define the clean task
Expand All @@ -27,9 +38,9 @@ $phulp->task('iterate_src_folder', function ($phulp) {
// Define the source folder
$phulp->src(['src/'], '/php$/', false)
->pipe($phulp->iterate(function ($distFile) {
\Phulp\Output::out(
\Phulp\Output::colorize('Iterated ->', 'green')
. ' ' . \Phulp\Output::colorize(
out::out(
out::colorize('Iterated ->', 'green')
. ' ' . out::colorize(
$distFile->getFullPath() . DIRECTORY_SEPARATOR . $distFile->getName(),
'blue'
)
Expand Down Expand Up @@ -77,9 +88,9 @@ $phulp->task('watch', function ($phulp) {
$phulp->watch(
$phulp->src(['src/'], '/php$/', false),
function ($phulp, $distFile) {
\Phulp\Output::out(
\Phulp\Output::colorize('File Changed ->', 'green')
. ' ' . \Phulp\Output::colorize(
out::out(
out::colorize('File Changed ->', 'green')
. ' ' . out::colorize(
$distFile->getFullPath() . DIRECTORY_SEPARATOR . $distFile->getName(),
'blue'
)
Expand All @@ -97,6 +108,8 @@ _If you have not configured the bin-dir:_
```bash
$ vendor/bin/phulp --help
$ vendor/bin/phulp # Will run the `default` task
$ vendor/bin/phulp --arg=repeat-clean:true # Will run the `default` task with the argument repeat-clean with value `true`
$ vendor/bin/phulp --autoload=/my/autoload/path/autoload.php # Will run the `default` task adding a alternative autoload php file
$ vendor/bin/phulp watch # Will run the `watch` task
```

Expand All @@ -119,6 +132,26 @@ $phulp->task('name', function ($phulp) {
});
```

### $phulp->getArguments()

Get all arguments.

```php
<?php

$arguments = $phulp->getArguments();
```

### $phulp->getArgument()

Get some argument value.

```php
<?php

$argument = $phulp->getArgument('argument-name', 'default-value-if-argument-does-not-exists');
```

### $phulp->clean()

Return for you an instance of `\Phulp\PipeIterate` that will iterate all src files and delete your parent directory.
Expand Down
23 changes: 17 additions & 6 deletions README.md
Expand Up @@ -43,9 +43,18 @@ $ composer require --dev reisraff/phulp

// filepath: /path/for/your/phulpfile.php

use Phulp\Output as out;

// Define the default task
$phulp->task('default', function ($phulp) {
out::out(out::colorize('Arguments:', 'green'));
out::out(print_r($phulp->getArguments(), true));

$phulp->start(['clean', 'iterate_src_folder', 'sync_command', 'async_command']);
if ($phulp->getArgument('repeat-clean', false)) {
out::out(out::colorize('Repeating "clean":', 'green'));
$phulp->start(['clean']);
}
});

// Define the clean task
Expand All @@ -62,9 +71,9 @@ $phulp->task('iterate_src_folder', function ($phulp) {
// Define the source folder
$phulp->src(['src/'], '/php$/', false)
->pipe($phulp->iterate(function ($distFile) {
\Phulp\Output::out(
\Phulp\Output::colorize('Iterated ->', 'green')
. ' ' . \Phulp\Output::colorize(
out::out(
out::colorize('Iterated ->', 'green')
. ' ' . out::colorize(
$distFile->getFullPath() . DIRECTORY_SEPARATOR . $distFile->getName(),
'blue'
)
Expand Down Expand Up @@ -112,9 +121,9 @@ $phulp->task('watch', function ($phulp) {
$phulp->watch(
$phulp->src(['src/'], '/php$/', false),
function ($phulp, $distFile) {
\Phulp\Output::out(
\Phulp\Output::colorize('File Changed ->', 'green')
. ' ' . \Phulp\Output::colorize(
out::out(
out::colorize('File Changed ->', 'green')
. ' ' . out::colorize(
$distFile->getFullPath() . DIRECTORY_SEPARATOR . $distFile->getName(),
'blue'
)
Expand All @@ -134,6 +143,8 @@ _If you have not configured the bin-dir:_
```bash
$ vendor/bin/phulp --help
$ vendor/bin/phulp # Will run the `default` task
$ vendor/bin/phulp --arg=repeat-clean:true # Will run the `default` task with the argument repeat-clean with value `true`
$ vendor/bin/phulp --autoload=/my/autoload/path/autoload.php # Will run the `default` task adding a alternative autoload php file
$ vendor/bin/phulp watch # Will run the `watch` task
```

Expand Down

0 comments on commit 1310707

Please sign in to comment.