Skip to content

Commit

Permalink
Merge pull request #53 from themsaid/tinker
Browse files Browse the repository at this point in the history
Add a tinker command
  • Loading branch information
taylorotwell authored Jun 9, 2020
2 parents 6a7226c + b526da0 commit 3a32399
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Commands/CommandCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function handle()
$command = $this->vapor->invoke(
Manifest::id(),
$environment = $this->argument('environment'),
$this->option('command') ?? Helpers::ask('What command would you like to execute')
$this->getCommand()
);

Helpers::step('<options=bold>Executing Function...</>'.PHP_EOL);
Expand Down Expand Up @@ -66,6 +66,16 @@ public function handle()
Helpers::line('<fg=magenta>AWS Log Stream Name:</> '.$command['log_stream']);
}

/**
* Get the command to run.
*
* @return string
*/
protected function getCommand()
{
return $this->option('command') ?? Helpers::ask('What command would you like to execute');
}

/**
* Wait for the given command to finish executing.
*
Expand Down
37 changes: 37 additions & 0 deletions src/Commands/TinkerCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Laravel\VaporCli\Commands;

use Laravel\VaporCli\Helpers;
use Laravel\VaporCli\Manifest;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

class TinkerCommand extends CommandCommand
{
/**
* Configure the command options.
*
* @return void
*/
protected function configure()
{
$this
->setName('tinker')
->addArgument('environment', InputArgument::OPTIONAL, 'The environment name', 'staging')
->addOption('code', null, InputOption::VALUE_OPTIONAL, 'The code to execute with Tinker')
->setDescription('Execute a code with Tinker');
}

/**
* Get the command to run.
*
* @return string
*/
protected function getCommand()
{
$code = $this->option('code') ?? Helpers::ask('What code would you like to execute');

return 'tinker --execute "'.$code.'"';
}
}
1 change: 1 addition & 0 deletions vapor
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ $app->add(new Commands\UpCommand);
// Commands / Invocations...
$app->add(new Commands\CommandCommand);
$app->add(new Commands\CommandLogCommand);
$app->add(new Commands\TinkerCommand);

// Logs...
$app->add(new Commands\TailCommand);
Expand Down

0 comments on commit 3a32399

Please sign in to comment.