Skip to content

Commit 122a2f5

Browse files
committed
fix(auth_commands): update save_credentials to append API keys if file exists
1 parent 779888e commit 122a2f5

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

penify_hook/commands/auth_commands.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,17 @@ def save_credentials(api_key):
1414
"""
1515
home_dir = Path.home()
1616
penify_file = home_dir / '.penify'
17+
1718

18-
credentials = {
19-
'api_keys': api_key
20-
}
19+
# if the file already exists, add the new api key to the existing file
20+
if penify_file.exists():
21+
with open(penify_file, 'r') as f:
22+
credentials = json.load(f)
23+
credentials['api_keys'] = api_key
24+
else:
25+
credentials = {
26+
'api_keys': api_key
27+
}
2128

2229
try:
2330
with open(penify_file, 'w') as f:

penify_hook/main.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ def main():
5151
"""
5252

5353
parser = argparse.ArgumentParser(description=description, formatter_class=argparse.RawDescriptionHelpFormatter)
54-
5554
# Create subparsers for the main commands
5655
subparsers = parser.add_subparsers(title="subcommands", dest="subcommand")
5756

0 commit comments

Comments
 (0)