From c09d56ac1e28d0e345952aceef04a879fd8d6852 Mon Sep 17 00:00:00 2001 From: Lenka Segura Date: Jul 27 2019 21:28:45 +0000 Subject: Register command groups the click way --- diff --git a/cranc/cranc.py b/cranc/cranc.py index 6559ad1..3f90546 100644 --- a/cranc/cranc.py +++ b/cranc/cranc.py @@ -36,12 +36,12 @@ def cranc(): # Creating subgroup 'get' -@click.group() +@cranc.group() def get(): pass -@click.command(name="prs") +@get.command(name="prs") @click.option("--status") @click.option("--assignee") @click.option("--author") @@ -64,7 +64,7 @@ def pr_list(status, assignee, author): get.add_command(pr_list) -@click.command(name="issues") +@get.command(name="issues") @click.option("--status") @click.option("--tags") @click.option("--assignee") @@ -108,12 +108,12 @@ get.add_command(issue_list) # Create subgroup 'merge' -@click.group() +@cranc.group() def merge(): pass -@click.command(name="pr") +@merge.command(name="pr") @click.option("--request_id") def merge_pr(request_id): """This command merges a pull request""" @@ -132,12 +132,12 @@ def merge_pr(request_id): merge.add_command(merge_pr) # Create subgroup 'create' -@click.group() +@cranc.group() def create(): pass -@click.command(name="pr") +@create.command(name="pr") @click.option("--repo_to") @click.option("--title") @click.option("--branch_to") @@ -163,14 +163,3 @@ def create_pr(repo_to, title, branch_to, branch_from, repo_from): except Exception: _log.exception("Failed to connect to the server") - -# Adding create_pr into the group 'create' -create.add_command(create_pr) - -################################################################################ -# General section -################################################################################ - -cranc.add_command(get) -cranc.add_command(merge) -cranc.add_command(create)