Skip to content

Commit 81130f4

Browse files
committed
minor fixes
1 parent 2349237 commit 81130f4

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ $ php your-script.php foo other arguments here
353353

354354
The `FooCommand` will be run with `other arguments here` as arguments.
355355

356+
**Note:** subcommands will always have the attributes `console`, `fs` and `templatesLoader` pointing to the same objects as their parent, as long as you don't change them explicitly in the subcommand's code.
357+
356358
# Testing Commands
357359

358360
The class `Tarsana\Tester\CommandTestCase` extends `PHPUnit\Framework\TestCase` and adds useful methods to test Tarsana Commands.
@@ -508,4 +510,6 @@ Please take a look at the examples in the `examples` directory, and try using th
508510

509511
# Development Notes
510512

513+
- **Version 1.0.1** Fixed a bug of subcommands having different instances of `fs` and `templatesLoader` from their parent.
514+
511515
- **Version 1.0.0** The first version is finally out; have fun!

src/Command.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ public static function create(callable $action = null) {
4343
public function __construct()
4444
{
4545
$this->commands([])
46-
->setupSubCommands()
4746
->name('Unknown')
4847
->version('1.0.0')
4948
->description('...')
5049
->descriptions([])
5150
->options([])
5251
->console(new Console)
5352
->fs(new Filesystem('.'))
53+
->setupSubCommands()
5454
->init();
5555
}
5656

src/SubCommand.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ public function __construct(Command $parent)
2323
{
2424
parent::__construct();
2525
$this->parent($parent)
26-
->console($parent->console);
26+
->console($parent->console())
27+
->fs($parent->fs)
28+
->templatesLoader($parent->templatesLoader);
2729
}
2830

2931
protected function setupSubCommands()

0 commit comments

Comments
 (0)