-
Notifications
You must be signed in to change notification settings - Fork 3
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
add github sub-url autocompletion #24
base: master
Are you sure you want to change the base?
Conversation
Given the condition that there exists a magicword with name github and that it points to a github repository doing: goto github iss[tab][tab] will now give suggestions from the github api on possible sub-urls: issue_comment issue_events issues Demonstration: https://asciinema.org/a/j3I9Ug9WP1WZuBR8KYk9pyd22
8fe6fa5
to
913f39a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it ! 👍
def parse_github_url(self, url): | ||
""" Extracts user and repo from url """ | ||
parts = url.split("github.com")[1].split("/") | ||
return parts[1], parts[2] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider naming your magic numbers
assert api.repo == "goto", "repo is not correct" | ||
|
||
|
||
def test_search_for_urls(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the tests 👍
exit(1) | ||
|
||
# going to sub-url in github | ||
if sys.argv[2] == 'github': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
command = sys.argv[2]`
if command == 'github':
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got ImportError: No module named requests
even though I ran pip3 install -r requirements.txt
.
I am suspecting goto is running python2 on ubuntu18
UPDATE
I ran pip install -r requirements.txt
and got the same result... wierd
@@ -0,0 +1,68 @@ | |||
# -*- coding: utf-8 -*- | |||
import requests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When doing a fresh install of this branch i got a missing requests error
jonas in ~/git/technocake/goto on feature/github-autocompletions
$ sudo ./uninstall.sh && sudo ./install.sh
remove the line: source start_goto from your bash config file
(most likely .bash_profile or .bashrc in your home folder)
Also, your data in ~/.goto is not deleted
Step 1: Installing goto into /usr/local/opt/goto
Step 2: Adding symlinks to /usr/local/bin
Step 3: Setting up magic data folder in /home/jonas/.goto
~/.bash_profile does not exist
To make goto function properly, add this line to your bash config file:
source start_goto
into one of these (.bashrc | .profile | .bash_profile)
Want to append to .bashrc? [y|n]: y
active project is now: goto
active project is now: goto
Traceback (most recent call last):
File "/usr/local/opt/goto/the_real_goto.py", line 9, in <module>
from gotomagic.githubmagic import GitHub
File "/usr/local/opt/goto/gotomagic/githubmagic.py", line 2, in <module>
import requests
ImportError: No module named requests
ERROR: Installation step failed with exit code 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UPDATE
I ran pip install -r requirements.txt
(python2-pip) and got the same result... wierd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UPDATE - Today pip2 works! Pip3 still not working
pip3: https://asciinema.org/a/y4R65wKjtsDxY1OvmFIznZYdi
pip2: https://asciinema.org/a/qLCM0R42RyKdTOqtiu3TmiZbV
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My python versions
$ python --version
Python 2.7.15rc1
$ python3 --version
Python 3.6.5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
goto uses "python" from the environment, not python3 so I guess you install requests with pip3 but goto finds python, which is symlinked to python2.7 -- and requests isn't installed there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Until this point, I made effort into making goto dependency-less - to solve these issues.
But it limits its design. I could implement standard python versions of both fetching urls (using urllib) and copying to clipboard ( using tkinter) -- it would remove dependencies.
Open to discuss.
Think structuring goto as a python package is the way to go if we choose to use dependencies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting discussion indeed. The idea of having as few dependencies as possible is very attractive. If Python has standard libraries which solves our problem (without having to jump through hoops) why not use them?
If standard libraries does not solve our problem, we have to look somewhere else.
autocomplete works
|
Given the condition that there exists a magicword with name github
and that it points to a github repository
doing: goto github iss[tab][tab]
will now give suggestions from the github api on possible sub-urls:
issue_comment issue_events issues
Demonstration: https://asciinema.org/a/j3I9Ug9WP1WZuBR8KYk9pyd22