Laravel dependency removed; Package now solely depends on Symfony's Console component.
+ Moved classes, modified paths to reflect dependency change.
This commit is contained in:
parent
914488bec2
commit
4720c49a85
|
|
@ -1,6 +1,6 @@
|
|||
# Laravel Console Writer
|
||||
# Console Writer
|
||||
|
||||
Console input/output writer for Laravel. Features a dedicated class for console
|
||||
interactivity for use with the Laravel Framework 5.8 and higher, allowing
|
||||
Console input/output writer for Symfony. Features a dedicated class for console
|
||||
interactivity based on Symfony's Console component, allowing
|
||||
easier styling through proper class inheritance while providing a simple and
|
||||
non-obstructive interface for use in your console commands.
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "danmaku/laravel-console-writer",
|
||||
"name": "danmaku/console-writer",
|
||||
"type": "library",
|
||||
"description": "Easily adaptable console input/output writer for Laravel.",
|
||||
"description": "Easily adaptable console input/output writer for Symfony.",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Marvin Schreurs",
|
||||
|
|
@ -14,7 +14,6 @@
|
|||
"email": "fristi@danmaku.moe"
|
||||
},
|
||||
"keywords": [
|
||||
"laravel",
|
||||
"console",
|
||||
"symfony"
|
||||
],
|
||||
|
|
@ -22,12 +21,11 @@
|
|||
"minimum-stability": "dev",
|
||||
"require": {
|
||||
"php": ">=7.2.0",
|
||||
"illuminate/console": "^5.8",
|
||||
"symfony/console": "^4.2"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Danmaku\\LaravelConsoleWriter\\": "src/"
|
||||
"Danmaku\\Console\\": "src/Console"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,11 +6,11 @@
|
|||
*
|
||||
* PHP version 7.2
|
||||
*
|
||||
* @package Danmaku\LaravelConsoleWriter\Console\Helper
|
||||
* @package Danmaku\Console\Helper
|
||||
* @author Marvin Schreurs <fristi@danmaku.moe>
|
||||
*/
|
||||
|
||||
namespace Danmaku\LaravelConsoleWriter\Console\Helper;
|
||||
namespace Danmaku\Console\Helper;
|
||||
|
||||
|
||||
use Symfony\Component\Console\Exception\RuntimeException;
|
||||
|
|
@ -27,7 +27,7 @@ use Symfony\Component\Console\Question\Question;
|
|||
/**
|
||||
* Class InheritableQuestionHelper
|
||||
*
|
||||
* @package Danmaku\LaravelConsoleWriter\Console\Helper
|
||||
* @package Danmaku\Console\Helper
|
||||
* @author Marvin Schreurs <fristi@danmaku.moe>
|
||||
*/
|
||||
class InheritableQuestionHelper extends \Symfony\Component\Console\Helper\QuestionHelper
|
||||
|
|
@ -6,11 +6,11 @@
|
|||
*
|
||||
* PHP version 7.2
|
||||
*
|
||||
* @package Danmaku\LaravelConsoleWriter\Console\Helper
|
||||
* @package Danmaku\Console\Helper
|
||||
* @author Marvin Schreurs <fristi@danmaku.moe>
|
||||
*/
|
||||
|
||||
namespace Danmaku\LaravelConsoleWriter\Console\Helper;
|
||||
namespace Danmaku\Console\Helper;
|
||||
|
||||
|
||||
use Symfony\Component\Console\Exception\RuntimeException;
|
||||
|
|
@ -28,7 +28,7 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
|||
/**
|
||||
* Class QuestionHelper
|
||||
*
|
||||
* @package Danmaku\LaravelConsoleWriter\Console\Helper
|
||||
* @package Danmaku\Console\Helper
|
||||
* @author Marvin Schreurs <fristi@danmaku.moe>
|
||||
*/
|
||||
class QuestionHelper extends InheritableQuestionHelper
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
/**
|
||||
* ChoiceQuestion class source file.
|
||||
*
|
||||
* Contains the source code of the ChoiceQuestion class.
|
||||
*
|
||||
* PHP version 7.2
|
||||
*
|
||||
* @package Danmaku\Console\Question
|
||||
* @author Marvin Schreurs <fristi@danmaku.moe>
|
||||
*/
|
||||
|
||||
namespace Danmaku\Console\Question;
|
||||
|
||||
|
||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Console\Question\ChoiceQuestion as SymfonyChoiceQuestion;
|
||||
|
||||
/**
|
||||
* Class ChoiceQuestion
|
||||
*
|
||||
* @package Danmaku\Console\Question
|
||||
* @author Marvin Schreurs <fristi@danmaku.moe>
|
||||
*/
|
||||
class ChoiceQuestion extends SymfonyChoiceQuestion
|
||||
{
|
||||
protected function isAssoc($array)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
/**
|
||||
* ConfirmationQuestion class source file.
|
||||
*
|
||||
* Contains the source code of the ConfirmationQuestion class.
|
||||
*
|
||||
* PHP version 7.2
|
||||
*
|
||||
* @package Danmaku\Console\Question
|
||||
* @author Marvin Schreurs <fristi@danmaku.moe>
|
||||
*/
|
||||
|
||||
namespace Danmaku\Console\Question;
|
||||
|
||||
|
||||
use Symfony\Component\Console\Question\ConfirmationQuestion as SymfonyConfirmationQuestion;
|
||||
|
||||
/**
|
||||
* Class ConfirmationQuestion
|
||||
*
|
||||
* @package Danmaku\Console\Question
|
||||
* @author Marvin Schreurs <fristi@danmaku.moe>
|
||||
*/
|
||||
class ConfirmationQuestion extends SymfonyConfirmationQuestion
|
||||
{
|
||||
protected function isAssoc($array)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
30
danmaku/console-writer/src/Console/Question/Question.php
Normal file
30
danmaku/console-writer/src/Console/Question/Question.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
/**
|
||||
* Question class source file.
|
||||
*
|
||||
* Contains the source code of the Question class.
|
||||
*
|
||||
* PHP version 7.2
|
||||
*
|
||||
* @package Danmaku\Console\Question
|
||||
* @author Marvin Schreurs <fristi@danmaku.moe>
|
||||
*/
|
||||
|
||||
namespace Danmaku\Console\Question;
|
||||
|
||||
|
||||
use Symfony\Component\Console\Question\Question as SymfonyQuestion;
|
||||
|
||||
/**
|
||||
* Class Question
|
||||
*
|
||||
* @package Danmaku\Console\Question
|
||||
* @author Marvin Schreurs <fristi@danmaku.moe>
|
||||
*/
|
||||
class Question extends SymfonyQuestion
|
||||
{
|
||||
protected function isAssoc($array)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +1,22 @@
|
|||
<?php
|
||||
/**
|
||||
* BaseOutputWriter class source file.
|
||||
* DefaultOutputWriter class source file.
|
||||
*
|
||||
* Contains the source code of the BaseOutputWriter class.
|
||||
* Contains the source code of the DefaultOutputWriter class.
|
||||
*
|
||||
* PHP version 7.2
|
||||
*
|
||||
* @package Danmaku\LaravelConsoleWriter\Console\Output
|
||||
* @package Danmaku\Console\Writer
|
||||
* @author Marvin Schreurs <fristi@danmaku.moe>
|
||||
*/
|
||||
|
||||
namespace Danmaku\LaravelConsoleWriter\Console\Output;
|
||||
namespace Danmaku\Console\Writer;
|
||||
|
||||
|
||||
use Danmaku\LaravelConsoleWriter\Console\Helper\QuestionHelper;
|
||||
use Danmaku\LaravelConsoleWriter\Console\Question\BaseChoiceQuestion;
|
||||
use Danmaku\LaravelConsoleWriter\Console\Question\BaseConfirmationQuestion;
|
||||
use Danmaku\LaravelConsoleWriter\Console\Question\BaseQuestion;
|
||||
use Danmaku\LaravelConsoleWriter\Console\Question\ChoiceQuestion;
|
||||
use Danmaku\LaravelConsoleWriter\Console\Question\ConfirmationQuestion;
|
||||
use Danmaku\LaravelConsoleWriter\Console\Question\Question;
|
||||
use Symfony\Component\Console\Exception\RuntimeException;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatter;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
|
||||
|
|
@ -27,18 +27,16 @@ use Symfony\Component\Console\Helper\Table;
|
|||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Question\ChoiceQuestion;
|
||||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
||||
use Symfony\Component\Console\Question\Question;
|
||||
use Symfony\Component\Console\Question\Question as SymfonyQuestion;
|
||||
use Symfony\Component\Console\Terminal;
|
||||
|
||||
/**
|
||||
* Class BaseOutputWriter
|
||||
* Class DefaultOutputWriter
|
||||
*
|
||||
* @package Danmaku\LaravelConsoleWriter\Console\Output
|
||||
* @package Danmaku\Console\Writer
|
||||
* @author Marvin Schreurs <fristi@danmaku.moe>
|
||||
*/
|
||||
class BaseOutputWriter implements OutputWriterInterface
|
||||
class DefaultOutputWriter implements OutputWriterInterface
|
||||
{
|
||||
/**
|
||||
* Console input interface.
|
||||
|
|
@ -268,7 +266,7 @@ class BaseOutputWriter implements OutputWriterInterface
|
|||
|
||||
public function ask(string $question, $default = null, $validator = null)
|
||||
{
|
||||
$question = new BaseQuestion($question, $default);
|
||||
$question = new Question($question, $default);
|
||||
$question->setValidator($validator);
|
||||
|
||||
return $this->askQuestion($question);
|
||||
|
|
@ -276,7 +274,7 @@ class BaseOutputWriter implements OutputWriterInterface
|
|||
|
||||
public function password(string $question, $validator = null)
|
||||
{
|
||||
$question = new BaseQuestion($question);
|
||||
$question = new Question($question);
|
||||
|
||||
$question->setHidden(true);
|
||||
$question->setValidator($validator);
|
||||
|
|
@ -286,12 +284,12 @@ class BaseOutputWriter implements OutputWriterInterface
|
|||
|
||||
public function confirm(string $question, $default = true): bool
|
||||
{
|
||||
return $this->askQuestion(new BaseConfirmationQuestion($question, $default));
|
||||
return $this->askQuestion(new ConfirmationQuestion($question, $default));
|
||||
}
|
||||
|
||||
public function choice(string $question, array $choices, $default = null)
|
||||
{
|
||||
return $this->askQuestion(new BaseChoiceQuestion($question, $choices, $default));
|
||||
return $this->askQuestion(new ChoiceQuestion($question, $choices, $default));
|
||||
}
|
||||
|
||||
public function startProgress(int $max = 0): void
|
||||
|
|
@ -367,11 +365,11 @@ class BaseOutputWriter implements OutputWriterInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Question $question
|
||||
* @param SymfonyQuestion $question
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function askQuestion(Question $question)
|
||||
protected function askQuestion(SymfonyQuestion $question)
|
||||
{
|
||||
if ($this->input->isInteractive()) {
|
||||
$this->autoPrependBlock();
|
||||
|
|
@ -6,11 +6,11 @@
|
|||
*
|
||||
* PHP version 7.2
|
||||
*
|
||||
* @package Danmaku\LaravelConsoleWriter\Console\Output
|
||||
* @package Danmaku\Console\Writer
|
||||
* @author Marvin Schreurs <fristi@danmaku.moe>
|
||||
*/
|
||||
|
||||
namespace Danmaku\LaravelConsoleWriter\Console\Output;
|
||||
namespace Danmaku\Console\Writer;
|
||||
|
||||
|
||||
use Symfony\Component\Console\Helper\ProgressBar;
|
||||
|
|
@ -19,7 +19,7 @@ use Symfony\Component\Console\Output\OutputInterface;
|
|||
/**
|
||||
* Interface OutputWriterInterface
|
||||
*
|
||||
* @package Danmaku\LaravelConsoleWriter\Console\Output
|
||||
* @package Danmaku\Console\Writer
|
||||
* @author Marvin Schreurs <fristi@danmaku.moe>
|
||||
*/
|
||||
interface OutputWriterInterface
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* BaseCommand class source file.
|
||||
*
|
||||
* Contains the source code of the BaseCommand class.
|
||||
*
|
||||
* PHP version 7.2
|
||||
*
|
||||
* @package Danmaku\LaravelConsoleWriter\Console\Command
|
||||
* @author Marvin Schreurs <fristi@danmaku.moe>
|
||||
*/
|
||||
|
||||
namespace Danmaku\LaravelConsoleWriter\Console\Command;
|
||||
|
||||
|
||||
use Danmaku\LaravelConsoleWriter\Console\Output\BaseOutputWriter;
|
||||
use Danmaku\LaravelConsoleWriter\Console\Output\OutputWriterInterface;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Console\OutputStyle;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* Class BaseCommand
|
||||
*
|
||||
* @package Danmaku\LaravelConsoleWriter\Console\Command
|
||||
* @author Marvin Schreurs <fristi@danmaku.moe>
|
||||
*/
|
||||
abstract class BaseCommand extends Command
|
||||
{
|
||||
/**
|
||||
* OutputWriterInterface instance.
|
||||
*
|
||||
* @var OutputWriterInterface $writer
|
||||
*/
|
||||
protected $writer;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->setOutputWriter($input, $output);
|
||||
return parent::execute($input, $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the output writer to use with this command.
|
||||
*/
|
||||
protected function setOutputWriter(InputInterface $input, OutputInterface $output): void
|
||||
{
|
||||
$this->writer = new BaseOutputWriter($input, $output);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* BaseChoiceQuestion class source file.
|
||||
*
|
||||
* Contains the source code of the BaseChoiceQuestion class.
|
||||
*
|
||||
* PHP version 7.2
|
||||
*
|
||||
* @package Danmaku\LaravelConsoleWriter\Console\Question
|
||||
* @author Marvin Schreurs <fristi@danmaku.moe>
|
||||
*/
|
||||
|
||||
namespace Danmaku\LaravelConsoleWriter\Console\Question;
|
||||
|
||||
|
||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Console\Question\ChoiceQuestion;
|
||||
|
||||
/**
|
||||
* Class BaseChoiceQuestion
|
||||
*
|
||||
* @package Danmaku\LaravelConsoleWriter\Console\Question
|
||||
* @author Marvin Schreurs <fristi@danmaku.moe>
|
||||
*/
|
||||
class BaseChoiceQuestion extends ChoiceQuestion
|
||||
{
|
||||
protected function isAssoc($array)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* BaseConfirmationQuestion class source file.
|
||||
*
|
||||
* Contains the source code of the BaseConfirmationQuestion class.
|
||||
*
|
||||
* PHP version 7.2
|
||||
*
|
||||
* @package Danmaku\LaravelConsoleWriter\Console\Question
|
||||
* @author Marvin Schreurs <fristi@danmaku.moe>
|
||||
*/
|
||||
|
||||
namespace Danmaku\LaravelConsoleWriter\Console\Question;
|
||||
|
||||
|
||||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
||||
|
||||
/**
|
||||
* Class BaseConfirmationQuestion
|
||||
*
|
||||
* @package Danmaku\LaravelConsoleWriter\Console\Question
|
||||
* @author Marvin Schreurs <fristi@danmaku.moe>
|
||||
*/
|
||||
class BaseConfirmationQuestion extends ConfirmationQuestion
|
||||
{
|
||||
protected function isAssoc($array)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* BaseQuestion class source file.
|
||||
*
|
||||
* Contains the source code of the BaseQuestion class.
|
||||
*
|
||||
* PHP version 7.2
|
||||
*
|
||||
* @package Danmaku\LaravelConsoleWriter\Console\Question
|
||||
* @author Marvin Schreurs <fristi@danmaku.moe>
|
||||
*/
|
||||
|
||||
namespace Danmaku\LaravelConsoleWriter\Console\Question;
|
||||
|
||||
|
||||
use Symfony\Component\Console\Question\Question;
|
||||
|
||||
/**
|
||||
* Class BaseQuestion
|
||||
*
|
||||
* @package Danmaku\LaravelConsoleWriter\Console\Question
|
||||
* @author Marvin Schreurs <fristi@danmaku.moe>
|
||||
*/
|
||||
class BaseQuestion extends Question
|
||||
{
|
||||
protected function isAssoc($array)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue