feat: write repository data to json file

This commit is contained in:
Aravinth Manivannan 2023-09-18 20:27:29 +05:30
parent 24ee32b561
commit d20026c680
Signed by: realaravinth
GPG key ID: F8F50389936984FF
2 changed files with 7 additions and 2 deletions

View file

@ -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):

View file

@ -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}")