Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
mantas6 committed Dec 30, 2024
1 parent 7b3b5ab commit 07b0dfd
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 209 deletions.
139 changes: 0 additions & 139 deletions base/.local/share/services/packages/zero/app/Commands/FzfDownload.php

This file was deleted.

54 changes: 0 additions & 54 deletions base/.local/share/services/packages/zero/app/Commands/FzfPhp.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use LaravelZero\Framework\Commands\Command;

use function Laravel\Prompts\search;
use function Mantas6\FzfPhp\fzf;

class AddCommand extends Command
{
Expand Down Expand Up @@ -35,18 +36,22 @@ public function handle()
->collect()
->mapWithKeys(fn (array $project) => [$project['id'] => $project['name']]);

$selected = search(
label: 'Select project',
scroll: 20,
options: fn (string $search) =>
$items->filter(fn (string $name) => str($name)->contains($search, ignoreCase: true))
->toArray()
$selected = fzf(
options: $items->map(fn ($name, $id) => "$id:$name")
->toArray(),

arguments: [
'delimiter' => ':',
'with-nth' => '2',
],
);

$index = str($selected)->before(':')->toString();

$project = Project::query()
->firstOrNew(['name' => $items[$selected]]);
->firstOrNew(['name' => $items[$index]]);

$project->ext_id = $selected;
$project->ext_id = $index;
$project->save();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
use Illuminate\Support\Facades\Storage;
use LaravelZero\Framework\Commands\Command;

use function Mantas6\FzfPhp\fzf;

class CopyCommand extends Command implements PromptsForMissingInput
{
/**
Expand Down Expand Up @@ -46,12 +48,11 @@ public function handle()
->tasks
->map(fn(Task $task) => $task->name);

Storage::put('tasks', $tasks->join("\n"));
$selected = fzf(
options: $tasks->toArray(),
arguments: ['tac' => true],
);

Process::pipe(function (Pipe $pipe) {
$pipe->command('cat ' . Storage::path('tasks'));
$pipe->command('fzf --tac');
$pipe->command('xc');
});
Process::input($selected)->run('xc');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Mantas6\FzfPhp\FuzzyFinder;

class AppServiceProvider extends ServiceProvider
{
Expand All @@ -11,7 +12,7 @@ class AppServiceProvider extends ServiceProvider
*/
public function boot(): void
{
//
// FuzzyFinder::usingCommand('/usr/bin/env fzf');
}

/**
Expand Down
1 change: 1 addition & 0 deletions base/.local/share/services/packages/zero/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"illuminate/database": "^11.5",
"laravel-zero/framework": "^11.0.2",
"laravel/serializable-closure": "^2.0",
"mantas6/fzf-php": "^0.1.1",
"saloonphp/laravel-http-sender": "^3.0",
"saloonphp/laravel-plugin": "^3.0",
"saloonphp/saloon": "^3.0"
Expand Down
65 changes: 64 additions & 1 deletion base/.local/share/services/packages/zero/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 07b0dfd

Please sign in to comment.