Skip to content

Commit

Permalink
Make CheckboxList trait complete again
Browse files Browse the repository at this point in the history
  • Loading branch information
bennothommo committed Sep 4, 2020
1 parent 68afc38 commit 4827e6d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
6 changes: 0 additions & 6 deletions src/Commands/InstallCheck/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ class Command extends BaseCommand
*/
protected static $defaultName = 'install:check';

/** @var Symfony\Component\Console\Output\ConsoleSectionOutput Current section */
protected $section = null;

/** @var string Current section text */
protected $sectionText = null;

/** @var bool If any checks have failed */
protected $failed = false;

Expand Down
25 changes: 16 additions & 9 deletions src/Traits/CheckboxList.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
<?php namespace BennoThommo\OctoberCli\Traits;

use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\ConsoleSectionOutput;

trait CheckboxList
{
/** @var OutputInterface Output interface */
protected $output;

/** @var ConsoleSectionOutput Current checkbox */
protected $checkbox = null;

/** @var string Current checkbox text */
protected $checkboxText = null;

/**
* Writes out a checkbox item to console.
*
Expand All @@ -15,34 +22,34 @@ trait CheckboxList
*/
protected function doCheck($text)
{
$this->section = $this->output->section();
$this->sectionText = $text;
$this->section->writeln('[ ] ' . $text);
$this->checkbox = $this->output->section();
$this->checkboxText = $text;
$this->checkbox->writeln('[ ] ' . $text);
}

protected function checkFailed()
{
$this->section->overwrite('[<error>X</error>] ' . $this->sectionText);
$this->checkbox->overwrite('[<error>X</error>] ' . $this->checkboxText);
if (func_num_args() > 0) {
$this->section->writeln("<comment> " . implode("\n ", func_get_args()) . '</comment>');
$this->checkbox->writeln("<comment> " . implode("\n ", func_get_args()) . '</comment>');
}
$this->failed = true;
}

protected function checkWarned()
{
$this->section->overwrite('[<warn>W</warn>] ' . $this->sectionText);
$this->checkbox->overwrite('[<warn>W</warn>] ' . $this->checkboxText);
if (func_num_args() > 0) {
$this->section->writeln("<comment> " . implode("\n ", func_get_args()) . '</comment>');
$this->checkbox->writeln("<comment> " . implode("\n ", func_get_args()) . '</comment>');
}
$this->warned = true;
}

protected function checkSuccessful()
{
$this->section->overwrite('[<success>✓</success>] ' . $this->sectionText);
$this->checkbox->overwrite('[<success>✓</success>] ' . $this->checkboxText);
if (func_num_args() > 0) {
$this->section->writeln("<comment> " . implode("\n ", func_get_args()) . '</comment>');
$this->checkbox->writeln("<comment> " . implode("\n ", func_get_args()) . '</comment>');
}
}
}

0 comments on commit 4827e6d

Please sign in to comment.