Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spark header suppression #4661

Merged
merged 1 commit into from
May 10, 2021
Merged
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion spark
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ error_reporting(-1);
ini_set('display_errors', '1');

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

$console->showHeader($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