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

add github sub-url autocompletion #24

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

technocake
Copy link
Owner

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

Robin Garen Aaberg added 4 commits September 19, 2018 03:03
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
Copy link
Collaborator

@Arxcis Arxcis left a 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]
Copy link
Collaborator

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():
Copy link
Collaborator

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':
Copy link
Collaborator

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':

Copy link
Collaborator

@Arxcis Arxcis left a 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
Copy link
Collaborator

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

Copy link
Collaborator

@Arxcis Arxcis Sep 19, 2018

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

Copy link
Collaborator

@Arxcis Arxcis Sep 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@Arxcis Arxcis Sep 20, 2018

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

Copy link
Owner Author

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

Copy link
Owner Author

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

Copy link
Collaborator

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.

@Arxcis
Copy link
Collaborator

Arxcis commented Sep 20, 2018

autocomplete works

$ goto github 
archive        commits        forks          issue_comment  milestones     statuses
assignees      compare        git            issue_events   mirror         subscribers
blobs          contents       git_commits    issues         notifications  subscription
branches       contributors   git_refs       keys           pulls          svn
clone          deployments    git_tags       labels         releases       tags
collaborators  downloads      hooks          languages      ssh            teams
comments       events         html           merges         stargazers     trees

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants