From d20026c68044d92d2d779c48f557d2ef9361d32b Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Mon, 18 Sep 2023 20:27:29 +0530 Subject: [PATCH] feat: write repository data to json file --- integration/cli.py | 6 +++++- integration/forgejo.py | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/integration/cli.py b/integration/cli.py index ffac8d5..728fe6a 100644 --- a/integration/cli.py +++ b/integration/cli.py @@ -147,7 +147,7 @@ class Forgejo: def run(args, c: Session): forgejo = forgejo_from_args(args, c=c) forgejo.login() - forgejo.create_access_token(name=args.name, file=args.file) + forgejo.create_access_token(name=args.name, file=args.file, repo=args.repo) self.create_access_token_parser = self.subparser.add_parser( name="create_access_token", @@ -164,6 +164,10 @@ class Forgejo: "file", type=str, help="filepath to write the token value" ) + self.create_access_token_parser.add_argument( + "repo", type=str, help="repo name write to json file" + ) + class Cli: def __init__(self): diff --git a/integration/forgejo.py b/integration/forgejo.py index afe56f2..0bfa38b 100755 --- a/integration/forgejo.py +++ b/integration/forgejo.py @@ -269,7 +269,7 @@ class Forgejo: ): raise Exception(f"Error while creating comment: {resp.status_code}") - def create_access_token(self, name: str, file: str): + def create_access_token(self, name: str, file: str, repo: str): """ Create access token """ @@ -296,6 +296,7 @@ class Forgejo: with open(file, "w") as f: data["login"] = self.username data["email"] = self.email + data["repo"] = repo content = json.dumps(data) f.write(content) print(f"Wrote access token to {file}")