Skip to content

Commit

Permalink
up: update the git emoji command, support render contents
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Dec 12, 2022
1 parent 80362d8 commit a9695a7
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion app/Console/SubCmd/GitxCmd/GitEmojiCmd.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Inhere\Console\Component\Symbol\GitEmoji;
use Inhere\Console\IO\Input;
use Inhere\Console\IO\Output;
use Inhere\Kite\Common\CmdRunner;
use Inhere\Kite\Console\Component\ContentsAutoReader;

/**
* class GitTagListCmd
Expand All @@ -24,6 +24,13 @@ public static function aliases(): array
return ['moji', 'emj'];
}

protected function getOptions(): array
{
return [
'-r, --replace' => 'replace :name: keywords to emoji for the input contents. allow: @c',
];
}

protected function getArguments(): array
{
return [
Expand All @@ -36,6 +43,14 @@ protected function execute(Input $input, Output $output)
$fs = $this->flags;
$ge = GitEmoji::new();

if ($src = $fs->getOpt('replace')) {
$src = ContentsAutoReader::readFrom($src);

$output->colored('RESULT:');
$output->println($ge->render($src));
return;
}

if ($kw = $fs->getArg('keywords')) {
$matched = $ge->search($kw);
if ($matched) {
Expand Down

0 comments on commit a9695a7

Please sign in to comment.