From 793c08baefc3b3f7923c76da1b9e07d95b42ab61 Mon Sep 17 00:00:00 2001 From: Lenka Segura Date: Dec 16 2018 15:46:06 +0000 Subject: add `cranc pr list` `cranc pr list` fetches all the pull requests from pagure project README.md also updated --- diff --git a/README.md b/README.md index 95feb39..ad7a050 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,10 @@ homepage: https://pagure.io/cranc ### What Cranc does -Nothing. -But soon it should be able to list pull requests. +At the moment cranc lists pull requests. +With this command: + +`cranc pr list` ### About its name @@ -18,13 +20,26 @@ Since 'pagure' is a hermit crab, cranc is crab in catalan. ` Create the virtual environment: -`python3 -m virtualenv env` -`source env/bin/activate` +`virtualenv3 ~/venvs/cranc-env` +`source ~/venvs/cranc-env/bin/activate` + +Retrieve the sources: + +`git clone https://pagure.io.cranc.git` +`cd cranc` Install dependencies: `pip install -t requirements.txt` +Run the setup file. This creates a link in the venv directory pointing to the cranc directory: + +`python setup.py develop` + Run the app: `cranc` + +Or run the command: + +`cranc pr list` diff --git a/cranc/cranc.py b/cranc/cranc.py index fa40ac8..195e37f 100644 --- a/cranc/cranc.py +++ b/cranc/cranc.py @@ -1,12 +1,45 @@ import click -import requests +import pprint + +from libpagure import libpagure @click.group() -def lists(): +def cranc(): pass -@click.command() -def list_pull_requests(): +api_token = os.getenv('CRANC_TOKEN') + + +################################################################################ +# PR section +################################################################################ + +@click.group() +def pr(): pass -lists.add_command(list_pull_requests) +@click.command() +#@click.option('--author', default='all') + +def list(): + """ + Get all pull requests of a project. + :param status: filters the status of the requests + :param assignee: filters the assignee of the requests + :param author: filters the author of the requests + :return: + """ + pagure = libpagure.Pagure(pagure_token=api_token, pagure_repository='pagure') + prs = pagure.list_requests() + + pprint.pprint(prs) + +pr.add_command(list) + + + +################################################################################ +# General section +################################################################################ + +cranc.add_command(pr) diff --git a/requirements.txt b/requirements.txt index 4ec164c..e5b399c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,5 @@ # Use this file by running "$ pip install -r requirements.txt" click +libpagure requests diff --git a/setup.py b/setup.py index 96e9dd8..4e423a4 100755 --- a/setup.py +++ b/setup.py @@ -16,6 +16,6 @@ setup( author_email='lenka@sepu.cz', entry_points=""" [console_scripts] - cranc=cranc.cranc:lists + cranc=cranc.cranc:cranc """ )