Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/Console/TinkerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Psy\Configuration;
use Psy\Shell;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

class TinkerCommand extends Command
{
Expand Down Expand Up @@ -64,6 +65,14 @@ public function handle()

$loader = ClassAliasAutoloader::register($shell, $path);

if ($code = $this->option('execute')) {
$shell->execute($code);

$loader->unregister();

return 0;
}

try {
$shell->run();
} finally {
Expand Down Expand Up @@ -129,4 +138,16 @@ protected function getArguments()
['include', InputArgument::IS_ARRAY, 'Include file(s) before starting tinker'],
];
}

/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return [
['execute', null, InputOption::VALUE_OPTIONAL, 'Execute the given code using Tinker'],
];
}
}