From 079c7d3d1a30ca6770a5da9273c06c117a44f763 Mon Sep 17 00:00:00 2001 From: Lenka Segura Date: Jan 22 2019 11:51:22 +0000 Subject: add cranc create pr --- diff --git a/cranc/cranc.py b/cranc/cranc.py index 4af76dc..a95e0c7 100644 --- a/cranc/cranc.py +++ b/cranc/cranc.py @@ -16,16 +16,12 @@ _log = logging.getLogger(__name__) # Creating a Pagure object PAGURE = libpagure.Pagure(pagure_token=api_token, pagure_repository=project) +# Creating group cranc @click.group() def cranc(): pass - -################################################################################ -# PR section -################################################################################ - - +# Creating subgroup 'get' @click.group() def get(): pass @@ -107,6 +103,27 @@ def merge_pr(request_id): # Adding merge_pr into the group 'merge' merge.add_command(merge_pr) +# Create subgroup 'create' +@click.group() +def create(): + pass + +@click.command(name="pr") +@click.option("--repo") +@click.option("--title") +@click.option("--branch_to") +@click.option("--branch_from") +def create_pr(repo, title, branch_to, branch_from): + """this command creates a new pull request""" + try: + request = PAGURE.create_pull_request(repo=repo, title=title, branch_to=branch_to, + branch_from=branch_from) + pprint.pprint(request) + except Exception: + _log.exception("Failed to connect to the server") + +# Adding create_pr into the group 'create' +create.add_command(create_pr) ################################################################################ # General section @@ -114,3 +131,4 @@ merge.add_command(merge_pr) cranc.add_command(get) cranc.add_command(merge) +cranc.add_command(create)