never mind minLength if --top enabled + delete obsolete files
This commit is contained in:
parent
5e1da51506
commit
ccf0506585
3 changed files with 4 additions and 48 deletions
|
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Lvl0\AnagramFinder\TUI;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class ArgHandler
|
||||
{
|
||||
private Collection $args;
|
||||
|
||||
public function __construct(array $argv)
|
||||
{
|
||||
$this->args = new Collection($argv);
|
||||
}
|
||||
|
||||
public static function make(array $argv): self
|
||||
{
|
||||
return new self($argv);
|
||||
}
|
||||
|
||||
public function get(int $index)
|
||||
{
|
||||
return $this->args
|
||||
->reject(fn($word) => substr($word, 0, 2) === '--')
|
||||
->get($index);
|
||||
}
|
||||
|
||||
public function hasOption(string $option)
|
||||
{
|
||||
return $this->args
|
||||
->filter(fn($word) => $word === '--' . $option)
|
||||
->isNotEmpty();
|
||||
}
|
||||
}
|
||||
|
|
@ -30,13 +30,15 @@ class FindAnagramWordsCommand extends Command
|
|||
info("ANAGRAM FINDER");
|
||||
|
||||
$anagram = $anagram ??= text("Enter the anagram", required: true);
|
||||
$minLength = $minLength ?: text(label: "Enter the minimum length of the results. (default=3)", placeholder: 3, default: 3, required: true);
|
||||
$minLength = $top === true
|
||||
? 3
|
||||
: ($minLength ?: text(label: "Enter the minimum length of the results. (default=3)", placeholder: 3, default: 3, required: true));
|
||||
|
||||
info("Results for your anagram: " . $anagram);
|
||||
|
||||
$matches = spin(
|
||||
callback: fn() => Matcher::findWords($anagram, $minLength),
|
||||
message: 'Checking wordlist...',
|
||||
message: 'Checking dictionary...',
|
||||
);
|
||||
|
||||
if ($top) {
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Lvl0\AnagramFinder\TUI;
|
||||
|
||||
class Output
|
||||
{
|
||||
public static function line(string $message = ''): void
|
||||
{
|
||||
print($message . PHP_EOL);
|
||||
flush();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue