furey / tinx

⛔️ Laravel Tinx is archived and no longer maintained.
449 stars 37 forks source link

Tinx does not remember command history #52

Closed TivoSoho closed 6 years ago

TivoSoho commented 6 years ago

I really like the idea behind this but unfortunately without command history being unavailable it is a bit useless to me. Command history should be available per current "session", after reload and even after closing and re-opening. History available = you can browse it with up and down. Tinker has this and I rely on this.

Tinx does seem to offer something but it is... weird. I cannot really describe it. It offers me things I have not typed this session instead of the command directly above that I just typed manually. And maybe if I hit "up" about 10 times I get the actual command I just ran... if it is even available.

ajthinking commented 6 years ago

Thanks for reporting! Can you give some example suggestions using numbers as statements? Something like below (tested on a mac)

php artisan tinx
1 
2 -> [1]
3 -> [2,1]
re() -> [3,2,1]
4 -> [re(), 3, 2, 1]
5 -> [4, re(), 3, 2, 1]
6 -> [5, 4, re(), 3, 2, 1]
exit -> [6, 5, 4, re(), 3, 2, 1]
php artisan tinx
7 -> [exit, 6, 5, 4, re(), 3, 2, 1] 

Can you also give details on your enviroment please.

furey commented 6 years ago

Hi @TivoSoho,

Sorry to hear command history isn't working as expected in your development environment.

Tinx/Tinker (via PsySH) has a "history" command (aka "hist") that might help debug this issue.

hist-command

Can I suggest running hist --clear to clear your command history, then run the commands you'd expect to be available via your command history, then finally run hist to inspect your command history and see if you can spot anything unusual?

As @ajthinking mentioned, if you can provide the following environment details that may help us too:

Cheers.

TivoSoho commented 6 years ago

I am running Homestead. PHP 7.2.3. Tinx 2.1.7 Laravel 5.7.2.

And after checking this issue is actually an Artisan problem, not Tinx. I just prefer to use Tinx and use it more and that is how it came out. I saw the history of commands behaving weird. It would be great however if it was possible for tinx team however to address this issue.

Basically if the command fails to execute properly it fails to add it to history. Unfortunately this to me is what tinker is for - tinkering, making sure that it does finish. Especially tinx since it offers the missing piece of re-loading to test the new code. So this means using dd or thrown exceptions break history.

An easy test to re-produce it is for example command: dd(1). It executes, but going up, it is not available. If you check the history you see it's not there.

furey commented 6 years ago

Hi @TivoSoho,

Ah right, gotcha.

Calling dd() directly in Tinx (or from anywhere within your codebase) will not commit the calling command to the Tinx/Tinker/PsySH history.

Had a quick look through PsySH's source and not quite sure how to solve this one…

…PR's welcome!

Cheers.