Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,21 @@ env: $(ENV_DIR)
setup:
$(PYTHON) -m venv $(ENV_DIR)
$(IN_ENV) python -m pip install --upgrade pip

requirements:
$(IN_ENV) python -m pip install --upgrade -r requirements.txt

build:
build: requirements
$(IN_ENV) python -m pip install --editable .

run:
@ $(IN_ENV) git-vain

test_requirements:
$(IN_ENV) python -m pip install --upgrade -r test_requirements.txt

star_repo:
$(IN_ENV) star-repo --star conor-f/spotibar

unstar_repo:
$(IN_ENV) star-repo --unstar conor-f/spotibar
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='git_vain',
version='0.0.1',
version='0.0.2',
python_requires='>=3.6',
description='',
long_description='',
Expand All @@ -19,7 +19,8 @@
install_requires=INSTALL_REQUIRES,
entry_points={
'console_scripts': [
'git-vain = git_vain.bin.git_vain:main'
'git-vain = git_vain.bin.git_vain:main',
'star-repo = git_vain.bin.star_repo:main'
]
}
)
45 changes: 45 additions & 0 deletions src/git_vain/bin/star_repo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import argparse
import yaml

from github import Github


def parse_args():
"""
Returns args including:
args.star == [True | False]
args.unstar == [True | False]
args.repo_name == str
"""
parser = argparse.ArgumentParser()

group = parser.add_mutually_exclusive_group(required=True)
group.add_argument("--star", action="store_true")
group.add_argument("--unstar", action="store_true")

parser.add_argument("repo_name")

return parser.parse_args()

def get_auth_token() -> str:
"""
Returns the Github auth token stored in the gh CLI config file.
"""
with open("/home/conor/.config/gh/config.yml", "r") as fh:
return yaml.safe_load(fh)["hosts"]["github.com"]["oauth_token"]

def main():
args = parse_args()
client = Github(get_auth_token())

print(args.repo_name)
if args.star:
client.get_user().add_to_starred(client.get_repo(args.repo_name))
elif args.unstar:
client.get_user().remove_from_starred(client.get_repo(args.repo_name))
else:
print("No action taken")


if __name__ == "__main__":
main()
2 changes: 2 additions & 0 deletions test_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PyGithub
pyyaml