File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 :
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments