55from datetime import datetime
66import httpx
77from collections import Counter
8+ from collectoss .util .keys import mask_key
89
910from collectoss .application .cli import test_connection , test_db_connection
1011
@@ -19,9 +20,16 @@ def cli():
1920 pass
2021
2122@cli .command ("api-keys" )
23+ @click .option (
24+ "--show-keys" ,
25+ is_flag = True ,
26+ default = False ,
27+ help = "Show full API keys instead of masking them." ,
28+ )
29+
2230@test_connection
2331@test_db_connection
24- def update_api_key ():
32+ def update_api_key (show_keys ):
2533 """
2634 Get the ratelimit of Github API keys
2735 """
@@ -63,24 +71,24 @@ def update_api_key():
6371
6472 graphql_requests = str (graphql_key_data ['requests_remaining' ]).center (len (graphql_request_header ))
6573 graphql_reset_time = str (epoch_to_local_time_with_am_pm (graphql_key_data ["reset_epoch" ])).center (len (graphql_reset_header ))
66-
67- print (f"{ key } | { core_requests } | { core_reset_time } | { graphql_requests } | { graphql_reset_time } |" )
74+ display_key = key if show_keys else mask_key ( key )
75+ print (f"{ display_key } | { core_requests } | { core_reset_time } | { graphql_requests } | { graphql_reset_time } |" )
6876
6977 valid_key_list = [x [0 ] for x in valid_key_data ]
7078 duplicate_keys = find_duplicates (valid_key_list )
7179 if len (duplicate_keys ) > 0 :
7280 print ("\n \n WARNING: There are duplicate keys this will slow down collection" )
7381 print ("Duplicate keys" .center (40 ))
7482 for key in duplicate_keys :
75- print (key )
83+ print (key if show_keys else mask_key ( key ) )
7684
7785
7886 if len (invalid_keys ) > 0 :
7987 invalid_key_header = "Invalid Keys" .center (40 )
8088 print ("\n " )
8189 print (invalid_key_header )
8290 for key in invalid_keys :
83- print (key )
91+ print (key if show_keys else mask_key ( key ) )
8492 print ("" )
8593
8694
0 commit comments