-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Povilas Susinskas
committed
Dec 15, 2016
1 parent
30c1127
commit 5514696
Showing
7 changed files
with
130 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
require __DIR__.'/vendor/autoload.php'; | ||
|
||
use Symfony\Component\Console\Application; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
use Povils\Figlet\Command\FigletCommand; | ||
|
||
$application = new Application('figlet', '1.0.0'); | ||
$command = new FigletCommand(); | ||
|
||
$application->add($command); | ||
|
||
$application->setDefaultCommand($command->getName(), true); | ||
$application->run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
|
||
/** | ||
* This is the part of Povils open-source library. | ||
* | ||
* @author Povilas Susinskas | ||
*/ | ||
|
||
namespace Povils\Figlet\Command; | ||
|
||
use Povils\Figlet\Figlet; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* Class FigletCommand | ||
* | ||
* @package Povils\Figlet\Command | ||
*/ | ||
class FigletCommand extends Command | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function configure() | ||
{ | ||
$this | ||
->setName('figlet') | ||
->setDescription('Writes figlet text in terminal') | ||
->addArgument('text', InputArgument::REQUIRED, 'Here should be figlet text') | ||
->addOption( | ||
'font', | ||
'f', | ||
InputOption::VALUE_OPTIONAL, | ||
'Figlet font', | ||
'big' | ||
) | ||
->addOption( | ||
'color', | ||
'c', | ||
InputOption::VALUE_OPTIONAL, | ||
'Figlet font color' | ||
) | ||
->addOption( | ||
'bg-color', | ||
'b', | ||
InputOption::VALUE_OPTIONAL, | ||
'Figlet background color' | ||
) | ||
->addOption( | ||
'stretching', | ||
's', | ||
InputOption::VALUE_OPTIONAL, | ||
'Add spaces between characters' | ||
) | ||
; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
|
||
$figlet = new Figlet(); | ||
$figlet | ||
->setFont($input->getOption('font')); | ||
|
||
if(null !== $input->getOption('color')){ | ||
$figlet->setFontColor($input->getOption('color')); | ||
} | ||
|
||
if(null !== $input->getOption('bg-color')){ | ||
$figlet->setBackgroundColor($input->getOption('bg-color')); | ||
} | ||
|
||
if(null !== $input->getOption('stretching')){ | ||
$figlet->setFontStretching($input->getOption('stretching')); | ||
} | ||
|
||
$output->write($figlet->render($input->getArgument('text'))); | ||
|
||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters