Skip to content

Commit 4cfee65

Browse files
Update cli.py
1 parent 5695213 commit 4cfee65

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

caltechdata_api/cli.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import argparse
22
import requests
33
import s3fs
4-
from caltechdata_api import caltechdata_write, caltechdata_edit, parse_readme_to_json
4+
from caltechdata_api import caltechdata_write, caltechdata_edit
5+
from md_to_json import parse_readme_to_json
56
import json
67
import os
78
from cryptography.fernet import Fernet
@@ -99,6 +100,16 @@ def get_or_set_token(production=True):
99100
print("Tokens do not match. Please try again.")
100101

101102

103+
# Delete the saved token file.
104+
def delete_saved_token():
105+
token_file = os.path.join(caltechdata_directory, "token.txt")
106+
if os.path.exists(token_file):
107+
os.remove(token_file)
108+
print("Token deleted successfully.")
109+
else:
110+
print("No token found to delete.")
111+
112+
102113
def welcome_message():
103114
print("Welcome to CaltechDATA CLI")
104115

@@ -458,14 +469,18 @@ def parse_args():
458469
parser.add_argument(
459470
"-test", action="store_true", help="Use test mode, sets production to False"
460471
)
472+
parser.add_argument(
473+
"--delete-token", action="store_true", help="Delete the saved token."
474+
)
461475
args = parser.parse_args()
462476
return args
463477

464478

465479
def main():
466480
args = parse_args()
467481
production = not args.test
468-
482+
if args.delete_token:
483+
delete_saved_token()
469484
while True:
470485
choice = get_user_input(
471486
"What would you like to do? (create/edit/profile/exit): "

0 commit comments

Comments
 (0)