@@ -29,13 +29,14 @@ def read_token():
2929 print (f"{ Fore .RED } ✕{ Fore .RESET } Error reading Token:\n { Fore .RED } { e } { Fore .RESET } " )
3030 return "error"
3131
32- def set_token (token ):
32+ def set_token (token , yes = False ):
3333 # 凭据 github-access-token.glm
3434 # == 移除 ==
3535 if token == "remove" :
36- print (f"{ Fore .YELLOW } ⚠{ Fore .RESET } Are you sure you want to remove the set Token?" )
3736 try :
38- input (f"Press { Fore .BLUE } Enter{ Fore .RESET } to confirm, press { Fore .BLUE } Ctrl + C{ Fore .RESET } to cancel..." )
37+ if not yes :
38+ print (f"{ Fore .YELLOW } ⚠{ Fore .RESET } Are you sure you want to remove the set Token?" )
39+ input (f"Press { Fore .BLUE } Enter{ Fore .RESET } to confirm, press { Fore .BLUE } Ctrl + C{ Fore .RESET } to cancel..." )
3940 keyring .delete_password ("github-access-token.glm" , "github-access-token" )
4041 print (f"{ Fore .GREEN } ✓{ Fore .RESET } The Token was successfully removed." )
4142 return "successful"
@@ -48,7 +49,7 @@ def set_token(token):
4849
4950 # == 添加 ==
5051 # --- Token 检查 ---
51- if not token .startswith ('ghp_' ):
52+ if not token .startswith ('ghp_' ) and not yes :
5253 print (f"{ Fore .YELLOW } ⚠{ Fore .RESET } Please check whether the Token is correct." )
5354 try :
5455 input (f"Press { Fore .BLUE } Enter{ Fore .RESET } to confirm, press { Fore .BLUE } Ctrl + C{ Fore .RESET } to cancel..." )
@@ -311,14 +312,15 @@ def main():
311312 parser_copy .add_argument ('--token' , type = str , help = 'GitHub Token' )
312313 parser_copy .add_argument ('--json' , type = str , help = 'Location of the Label data json file (default: labels-temp.json in the glm directory)' )
313314 parser_copy .add_argument ('--save' , help = 'Reserve the Label data json file' , action = 'store_true' )
314- parser_clear .add_argument ('--yes' , help = 'Ignore (confirm directly) all prompts in the operation' , action = 'store_true' )
315+ parser_copy .add_argument ('--yes' , help = 'Ignore (confirm directly) all prompts in the operation' , action = 'store_true' )
315316
316317 # 命令:config
317318 parser_config = subparsers .add_parser ('config' , help = 'Modify the configuration of the program' )
318319 parser_config .add_argument ('--token' , type = str , help = 'Set GitHub Token' )
319320 parser_config .add_argument ('--edit' , help = 'Open configuration file' , action = 'store_true' )
320321 parser_config .add_argument ('--version' , help = 'Displays the version of GitHub Labels Manager (GLM)' , action = 'store_true' )
321322 parser_config .add_argument ('--show' , help = 'Show current configuration' , action = 'store_true' )
323+ parser_config .add_argument ('--yes' , help = 'Ignore (confirm directly) all prompts in the operation' , action = 'store_true' )
322324
323325 # 命令:clear
324326 parser_clear = subparsers .add_parser ('clear' , help = 'Clear labels' )
@@ -393,7 +395,7 @@ def main():
393395
394396 print (f"{ Fore .GREEN } ✓{ Fore .RESET } Current configuration information:\n Account configuration:\n Token: { token } \n Program configuration:\n Version: { Fore .BLUE } GitHub Labels Manager v{ version } by 鸭鸭「カモ」{ Fore .RESET } \n Installed in: { Fore .BLUE } { script_path } { Fore .RESET } " )
395397 elif args .token :
396- running_result = set_token (args .token )
398+ running_result = set_token (args .token , args . yes )
397399 if running_result == "error" :
398400 return 1 , running_result
399401 elif args .edit :
0 commit comments