Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotkeys and Screen Emulator #4

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
6c9d921
add feature: custom hot key for commands
mergehez Nov 7, 2024
771a858
update readme with the new "custom hot key" feature
mergehez Nov 7, 2024
1db4895
default customHotKeys to an empty array instead of null
mergehez Nov 7, 2024
5527070
add "when" param and "isActive" method to CustomHotKey
mergehez Nov 7, 2024
a3742c0
add "execute" method to CustomHotKey
mergehez Nov 7, 2024
2232e16
log executed custom hotkey
mergehez Nov 7, 2024
e23ff40
Update README.md
mergehez Nov 7, 2024
8db6ab4
Merge branch 'main' into pr/4
aarondfrancis Nov 8, 2024
5cc43a1
WIP
aarondfrancis Nov 14, 2024
72ba102
wip
aarondfrancis Nov 19, 2024
e6d76f3
Merge branch 'main' into pr/4
aarondfrancis Nov 20, 2024
f30ecdd
pint
aarondfrancis Nov 20, 2024
bc721bb
Testing WIP
aarondfrancis Nov 30, 2024
f126f7a
Fix signing
aarondfrancis Dec 1, 2024
affa6f6
Pint
aarondfrancis Dec 1, 2024
97c0090
better
aarondfrancis Dec 1, 2024
7d53689
Merge branch 'main' into pr/4
aarondfrancis Dec 1, 2024
0141b24
Better tests
aarondfrancis Dec 1, 2024
04c4fe2
clean up tests
aarondfrancis Dec 1, 2024
20ff9f5
touch
aarondfrancis Dec 1, 2024
dcee19b
Enforce min width
aarondfrancis Dec 1, 2024
93cffdf
Shim
aarondfrancis Dec 1, 2024
06f1f7c
Fix ansi splice
aarondfrancis Dec 2, 2024
1c8d4fa
fix
aarondfrancis Dec 2, 2024
dfcbcfe
Add more info
aarondfrancis Dec 2, 2024
c95b8e8
Fix bug where process restarts too quickly.
aarondfrancis Dec 2, 2024
414b4bd
Fix tests
aarondfrancis Dec 3, 2024
1e832a6
Test
aarondfrancis Dec 3, 2024
4ca8322
Use screen for everything
aarondfrancis Dec 4, 2024
2c0b21f
Break out ansi match
aarondfrancis Dec 8, 2024
c825872
Move ansi aware
aarondfrancis Dec 8, 2024
93ac6e6
trim excess lines
aarondfrancis Dec 9, 2024
ac60357
bump
aarondfrancis Dec 9, 2024
c76a83e
bump
aarondfrancis Dec 9, 2024
2d42d6c
fix
aarondfrancis Dec 10, 2024
4922483
bump
aarondfrancis Dec 10, 2024
7d14098
test
aarondfrancis Dec 10, 2024
db4e63f
test
aarondfrancis Dec 10, 2024
7b391e2
Fix enhanced tail command
aarondfrancis Dec 10, 2024
ff78892
Enhanced logs
aarondfrancis Dec 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ jobs:
dependency-version: [ prefer-lowest, prefer-stable ]
include:
- laravel: 10.*
testbench: 8.*
- laravel: 11.*
testbench: 9.*


name: P${{ matrix.php }} / L${{ matrix.laravel }} / ${{ matrix.dependency-version }}

Expand All @@ -47,7 +44,7 @@ jobs:
- name: Install dependencies
run: |
composer self-update ${{ matrix.composer-version }}
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction

- name: Execute tests
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
artisan
.idea
.phpunit.result.cache
build
Expand Down
58 changes: 41 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class SoloServiceProvider extends ServiceProvider
EnhancedTailCommand::make('Logs', 'tail -f -n 100 ' . storage_path('logs/laravel.log')),
'Vite' => 'npm run dev',
// 'HTTP' => 'php artisan serve',
new Command(name: 'Foo', command: 'pwd"', autostart: false, customHotKeys: []),
'About' => 'php artisan solo:about'
])
// Not auto-started
Expand Down Expand Up @@ -126,6 +127,7 @@ Solo::useTheme('dark')
EnhancedTailCommand::make('Logs', 'tail -f -n 100 ' . storage_path('logs/laravel.log')),
'Vite' => 'npm run dev',
// 'HTTP' => 'php artisan serve',
new Command(name: 'Foo', command: 'pwd"', autostart: false, customHotKeys: []),
'About' => 'php artisan solo:about'
])
```
Expand All @@ -134,6 +136,31 @@ Solo::useTheme('dark')

To remove a command, simply delete the command. No need to create a PR to fix the stub. We've provided a reasonable set of starting commands, but the `SoloServiceProvider` lives in your application, so you have full control of it.

## Adding custom hotkeys to commands

To add custom hot keys for a command, you can pass an array of `AaronFrancis\Solo\Console\CustomHotKey` instances to the `customHotKeys` parameter of the `Command` constructor.

For example, notice the `CustomHotKey` array here:

```php
Solo::useTheme('dark')
// Commands that auto start.
->addCommands([
// ...
new Command(name: 'Foo', command: 'echo "See hotkeys below"', autostart: true, customHotKeys: [
new CustomHotKey(
key: 'e',
name: 'echoE',
callback: fn() => Log::info('pressed "e"...'),
when: fn(Command $command) => $command->processRunning()
),
new CustomHotKey(key: 'f', name: 'echoF', callback: fn() => Log::info('pressed "f"...')),
]),
])
```

The `when` parameter is optional. If provided, the hot key will only be active when the `when` callback returns `true`. This can be useful for hot keys that only make sense when a process is running.

## Usage

To use Solo, you simply need to run `php artisan solo`.
Expand Down Expand Up @@ -209,22 +236,19 @@ If you want to support me you can either buy one of my courses or tell your frie
- High Performance SQLite: https://highperformancesqlite.com
- Screencasting: https://screencasting.com


## FAQ

<dl>
<dt>My command isn't working</dt>
<dd>(That's not really a question, but I'll allow it.) Does it work outside of Solo? Does it have an `--ansi`
option? Is it writing to somewhere besides `STDOUT`? Is there an option to force it to write to `STDOUT`? If
you've tried all that, feel free to open an issue.
</dd>
<dt>Can I run Sail commands?</dt>
<dd>Yes! This seems to be the way to do it: `vendor/bin/sail artisan schedule:work --ansi` (Read more at #29.)
</dd>
<dt>Does Solo support Windows?</dt>
<dd>It does not, sorry. Solo relies on `ext-pcntl` and a few other Linux-y things, so Windows support is not on the
roadmap.
</dd>
<dt>Can I use this in production?</dt>
<dd>I wouldn't. I'd use something more robust, like supervisor or something.</dd>
</dl>
#### My command isn't working
(That's not really a question, but I'll allow it.) Does it work outside of Solo? Does it have an `--ansi`
option? Is it writing to somewhere besides `STDOUT`? Is there an option to force it to write to `STDOUT`? If
you've tried all that, feel free to open an issue.

#### Can I run Sail commands?
Yes! This seems to be the way to do it: `vendor/bin/sail artisan schedule:work --ansi` (Read more at #29.)

#### Does Solo support Windows?
It does not, sorry. Solo relies on `ext-pcntl` and a few other Linux-y things, so Windows support is not on the
roadmap.

#### Can I use this in production?
I wouldn't. I'd use something more robust, like supervisor or something.
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@
"require-dev": {
"illuminate/database": "^10|^11",
"phpunit/phpunit": "^10.5|^11",
"orchestra/testbench": "^8|^9"
"orchestra/testbench": "^8.29|^9.5",
"laravel/serializable-closure": "^1.3"
},
"autoload": {
"psr-4": {
"AaronFrancis\\Solo\\": "src/"
}
},
"autoload-dev": {
"files": [
"tests/Support/helpers.php"
],
"psr-4": {
"AaronFrancis\\Solo\\Tests\\": "tests/",
"App\\": "workbench/app/"
Expand Down
17 changes: 17 additions & 0 deletions config/solo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Themes
|--------------------------------------------------------------------------
|
| We have provided 'light' and 'dark' themes. If you prefer to
| register your own theme, you are free to do that via the
| Facade: Solo::registerTheme('name', MyAwesomeTheme::class);
|
*/
'theme' => env('SOLO_THEME', 'dark'),

'hotkeys' => env('SOLO_KEYBINDINGS', 'default')
];
Loading