feat: write repository data to json file
This commit is contained in:
parent
24ee32b561
commit
d20026c680
2 changed files with 7 additions and 2 deletions
|
@ -147,7 +147,7 @@ class Forgejo:
|
||||||
def run(args, c: Session):
|
def run(args, c: Session):
|
||||||
forgejo = forgejo_from_args(args, c=c)
|
forgejo = forgejo_from_args(args, c=c)
|
||||||
forgejo.login()
|
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(
|
self.create_access_token_parser = self.subparser.add_parser(
|
||||||
name="create_access_token",
|
name="create_access_token",
|
||||||
|
@ -164,6 +164,10 @@ class Forgejo:
|
||||||
"file", type=str, help="filepath to write the token value"
|
"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:
|
class Cli:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
@ -269,7 +269,7 @@ class Forgejo:
|
||||||
):
|
):
|
||||||
raise Exception(f"Error while creating comment: {resp.status_code}")
|
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
|
Create access token
|
||||||
"""
|
"""
|
||||||
|
@ -296,6 +296,7 @@ class Forgejo:
|
||||||
with open(file, "w") as f:
|
with open(file, "w") as f:
|
||||||
data["login"] = self.username
|
data["login"] = self.username
|
||||||
data["email"] = self.email
|
data["email"] = self.email
|
||||||
|
data["repo"] = repo
|
||||||
content = json.dumps(data)
|
content = json.dumps(data)
|
||||||
f.write(content)
|
f.write(content)
|
||||||
print(f"Wrote access token to {file}")
|
print(f"Wrote access token to {file}")
|
||||||
|
|
Loading…
Reference in a new issue