Skip to content

Commit 060b28e

Browse files
feat: config (--token) 命令可以通过添加 --yes 参数忽略(直接确认)操作中的所有提示
详细修改内容: - feat: config (--token) 命令可以通过添加 --yes 参数忽略(直接确认)操作中的所有提示 - fix: 修正了 d2def1e 错误的参数添加 - i18n
1 parent d2def1e commit 060b28e

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

other-languages/en_US/glm.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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:

程序脚本/glm.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ def read_token():
2929
print(f"{Fore.RED}{Fore.RESET} 读取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} 确定要移除设置的Token?")
3736
try:
38-
input(f"按{Fore.BLUE}Enter{Fore.RESET}键确认,按{Fore.BLUE}Ctrl + C{Fore.RESET}键取消...")
37+
if not yes:
38+
print(f"{Fore.YELLOW}{Fore.RESET} 确定要移除设置的Token?")
39+
input(f"按{Fore.BLUE}Enter{Fore.RESET}键确认,按{Fore.BLUE}Ctrl + C{Fore.RESET}键取消...")
3940
keyring.delete_password("github-access-token.glm", "github-access-token")
4041
print(f"{Fore.GREEN}{Fore.RESET} 成功移除设置的Token")
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} 请确认Token是否正确")
5354
try:
5455
input(f"按{Fore.BLUE}Enter{Fore.RESET}键确认,按{Fore.BLUE}Ctrl + C{Fore.RESET}键取消...")
@@ -311,14 +312,15 @@ def main():
311312
parser_copy.add_argument('--token', type=str, help='GitHub访问令牌')
312313
parser_copy.add_argument('--json', type=str, help='标签数据文件的存放位置(默认为glm所在目录下的labels-temp.json)')
313314
parser_copy.add_argument('--save', help='保留获取到的标签数据文件', action='store_true')
314-
parser_clear.add_argument('--yes', help='忽略(直接确认)操作中的所有提示', action='store_true')
315+
parser_copy.add_argument('--yes', help='忽略(直接确认)操作中的所有提示', action='store_true')
315316

316317
# 命令:config
317318
parser_config = subparsers.add_parser('config', help='修改配置')
318319
parser_config.add_argument('--token', type=str, help='设置GitHub访问令牌')
319320
parser_config.add_argument('--edit', help='打开配置文件', action='store_true')
320321
parser_config.add_argument('--version', help='显示GLM版本', action='store_true')
321322
parser_config.add_argument('--show', help='显示当前配置', action='store_true')
323+
parser_config.add_argument('--yes', help='忽略(直接确认)操作中的所有提示', action='store_true')
322324

323325
# 命令:clear
324326
parser_clear = subparsers.add_parser('clear', help='清空标签')
@@ -393,7 +395,7 @@ def main():
393395

394396
print(f"{Fore.GREEN}{Fore.RESET} 当前配置信息如下:\n 账户设置:\n Token: {token}\n 程序设置:\n 版本: {Fore.BLUE}GitHub Labels Manager v{version} by 鸭鸭「カモ」{Fore.RESET}\n 安装在: {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

Comments
 (0)