Skip to content

Commit

Permalink
Add no-header to spark
Browse files Browse the repository at this point in the history
  • Loading branch information
MGatner committed May 9, 2021
1 parent 82285f9 commit 4dc1b90
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
7 changes: 6 additions & 1 deletion spark
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ error_reporting(-1);
ini_set('display_errors', '1');

// Show basic information before we do anything else.
$console->showHeader();
if (false !== $suppress = array_search('--no-header', $_SERVER['argv'], true))
{
unset($_SERVER['argv'][$suppress]); // @codeCoverageIgnore
}

$console->showHeader((bool) $suppress);

// fire off the command in the main framework.
$response = $console->run();
Expand Down
9 changes: 8 additions & 1 deletion system/CLI/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,16 @@ public function run(bool $useSafeOutput = false)

/**
* Displays basic information about the Console.
*
* @param boolean $suppress
*/
public function showHeader()
public function showHeader(bool $suppress = false)
{
if ($suppress)
{
return;
}

CLI::write(sprintf('CodeIgniter v%s Command Line Tool - Server Time: %s UTC%s', CodeIgniter::CI_VERSION, date('Y-m-d H:i:s'), date('P')), 'green');
CLI::newLine();
}
Expand Down
8 changes: 8 additions & 0 deletions tests/system/CLI/ConsoleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ public function testHeader()
$this->assertTrue(strpos($result, sprintf('CodeIgniter v%s Command Line Tool', CodeIgniter::CI_VERSION)) > 0);
}

public function testNoHeader()
{
$console = new Console($this->app);
$console->showHeader(true);
$result = CITestStreamFilter::$buffer;
$this->assertSame('', $result);
}

public function testRun()
{
$request = new CLIRequest(config('App'));
Expand Down
4 changes: 4 additions & 0 deletions user_guide_src/source/cli/cli_commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ Some commands take additional arguments, which should be provided directly after

> php spark db:seed DevUserSeeder

You may always pass ``--no-header`` to suppress the header output, helpful for parsing results::

> php spark cache:clear --no-header

For all of the commands CodeIgniter provides, if you do not provide the required arguments, you will be prompted
for the information it needs to run correctly::

Expand Down

0 comments on commit 4dc1b90

Please sign in to comment.