PyBites-Open-Source / eatlocal

This package helps users solve PyBites code challenges on their local machine.
MIT License
20 stars 9 forks source link

New go-to command #26

Closed pmayd closed 2 weeks ago

pmayd commented 2 years ago

I would like to add a go-to command that takes the use to either the root of the repo if no argument is given or to the bite subfolder in the terminal. So eatlocal goto would change the directory to the root of the repo and eatlocal goto 1 would change directory to repo/1. This can be helpful if you want to execute some things in the terminal like call git or pytest

rhelmstedter commented 2 years ago

Sounds good to me.

pmayd commented 2 years ago

Seems not possible...I found a lot about os.chdir() but that is not changing the directory outside of the Python runtime in the console so right now I don't have a solution how to implement this

rhelmstedter commented 2 years ago

So does that mean you would have to essentially run it in the background the whole time?

pmayd commented 2 years ago

No it means you can change the current directory within your main program so that Path().cwd() changes or is alerted but I wanted to redirect the user in their current terminal session so that the goto command would actually take the user to the bite folder even after leaving the eatlocal program but I guess for this eatlocal would have to somehow interact with the current terminal session and I am not aware how to do that. One thing I wanted to dry it is to use a simple subprocess.run with cd because cd is the same command for windows and Linux and maybe this would work

rhelmstedter commented 2 years ago

I generally do that within my editor (neovim). Until you can find a pythonic solution, a cheater temporary way could be to alias eatlocal_goto to cd into the root directory: alias eatlocal_goto="cd path/to/repo".

I already have the following aliases:

alias ed="eatlocal download"
alias es="eatlocal submit"
alias er="eatlocal display"

Edit: Oh sorry, I forgot you are on windows. Aliasing is more difficult there.

WillCodesThings commented 1 year ago

What if you spin up a new terminal instance based on the os, then use a copy paste python module to change the directory in that new terminal window. You could also send artificial keypresses and detections with pyautogui

rhelmstedter commented 2 weeks ago

@pmayd is this feature still something you are interested in? Moving forward in v2, bites are saved by title instead of number. you can check out the proposed pull request #36 if you want.

pmayd commented 2 weeks ago

Well that was three years ago :D I was not even aware I ever proposed something like this. Nice to see that you are still working on it. Let me know if you need some help with the next version

rhelmstedter commented 2 weeks ago

Time flies! Ok, I'll close this issue for now. Bob just reviewed v2 so I'm hoping to merge this week.