Skip to content

Commit 31f1f30

Browse files
committed
Use rawstr4c for usage and -v
1 parent 2ea11f3 commit 31f1f30

File tree

3 files changed

+183
-105
lines changed

3 files changed

+183
-105
lines changed

src/chsrc-main.c

Lines changed: 6 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -139,92 +139,7 @@
139139

140140
#include "recipe/menu.c"
141141

142-
143-
static const char *
144-
USAGE_CHINESE =
145-
R"(名称:
146-
chsrc - Change Source - (GPLv3+) - Developed by RubyMetric
147-
148-
版本:
149-
@ver@
150-
151-
使用:
152-
chsrc <command> [options] [target] [mirror]
153-
154-
命令:
155-
help, h 打印此帮助 -h, --help
156-
issue 查看相关issue
157-
158-
list, ls, l 列出可用镜像站和可换源目标
159-
list mirror|target 列出支持的: 镜像站/换源目标
160-
list os|lang|ware 列出支持的: 操作系统/编程语言/软件
161-
list <target> 查看该目标可用源与支持功能
162-
163-
measure, m, cesu <target> 对该目标所有源测速
164-
165-
get, g <target> 查看该目标当前源的使用情况
166-
167-
set, s <target> 换源自动测速后挑选最快源
168-
set <target> first 换源使用维护团队测速第一的源
169-
set <target> <mirror> 换源指定使用某镜像站 (通过list <target>查看)
170-
set <target> <URL> 换源用户自定义源URL
171-
reset <target> 重置使用上游默认使用的源
172-
173-
选项:
174-
-dry Dry Run模拟换源过程命令仅打印并不运行
175-
-local 仅对本项目而非全局换源 (通过ls <target>查看支持情况)
176-
-ipv6 使用IPv6测速
177-
-en(glish) 使用英文输出
178-
-no-color 无颜色输出
179-
180-
维护:
181-
邀请您担任 Chef, 为用户把关您熟悉的 recipe
182-
源代码地址: @url@
183-
成为维护者: https://github.com/RubyMetric/chsrc/issues/130)";
184-
185-
186-
static const char *
187-
USAGE_ENGLISH =
188-
R"(NAME:
189-
chsrc - Change Source - (GPLv3+) - Developed by RubyMetric
190-
191-
VERSION:
192-
@ver@
193-
194-
USAGE:
195-
chsrc <command> [options] [target] [mirror]
196-
197-
COMMANDS:
198-
help, h Print this help, or -h, --help
199-
issue See related issues
200-
201-
list, ls, l List available mirror sites and supported targets
202-
list mirror|target List supported: mirror sites/supported targets
203-
list os|lang|ware List supported: OSes/Programming Languages/Softwares
204-
list <target> View available sources and supporting features for <target>
205-
206-
measure, m, cesu <target> Measure velocity of all sources of <target>
207-
208-
get, g <target> View the current source state for <target>
209-
210-
set, s <target> Change source, select the fastest source by automatic speed measurement
211-
set <target> first Change source, select the fastest source measured by the maintainers team
212-
set <target> <mirror> Change source, specify a mirror site (Via `list <target>`)
213-
set <target> <URL> Change source, using user-defined source URL
214-
reset <target> Reset source to the upstream's default
215-
216-
OPTIONS:
217-
-dry Dry Run. Simulate the source changing process, command only prints, not run
218-
-local Change source only for this project rather than globally (Via `ls <target>`)
219-
-ipv6 Speed measurement using IPv6
220-
-en(glish) Output in English
221-
-no-color Output without color
222-
223-
MAINTAIN:
224-
We invite you to become a Chef to ensure the quality of recipes you are familiar with for users:
225-
226-
Source Code: @url@,
227-
Become a Maintainer: https://github.com/RubyMetric/chsrc/issues/130)";
142+
#include "rawstr4c.h"
228143

229144

230145

@@ -425,13 +340,8 @@ cli_print_target_features (Feature_t f, const char *input_target_name)
425340
void
426341
cli_print_version ()
427342
{
428-
say ("chsrc " Chsrc_Version);
429-
say (R"(Copyright (C) 2025 Aoran Zeng, Heng Guo
430-
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
431-
This is free software: you are free to change and redistribute it.
432-
There is NO WARRANTY, to the extent permitted by law.
433-
434-
Written by Aoran Zeng, Heng Guo and contributors. (See chsrc-main.c))");
343+
char *str = xy_str_gsub (RAWSTR_chsrc_for_v, "@ver@", Chsrc_Version);
344+
print (str);
435345
}
436346

437347

@@ -440,27 +350,18 @@ cli_print_help ()
440350
{
441351
char *version_string = purple("v" Chsrc_Version "-" Chsrc_Release_Date);
442352

443-
const char *raw = CHINESE ? USAGE_CHINESE : USAGE_ENGLISH;
353+
const char *raw = CHINESE ? RAWSTR_chsrc_USAGE_CHINESE : RAWSTR_chsrc_USAGE_ENGLISH;
444354

445355
char *str = xy_str_gsub (raw, "@ver@", version_string);
446356
str = xy_str_gsub (str, "@url@", Chsrc_Maintain_URL);
447-
println (str);
357+
print (str);
448358
}
449359

450360

451361
void
452362
cli_print_issues ()
453363
{
454-
say (R"(
455-
We accept issues both sides on Gitee and Github
456-
457-
- https://gitee.com/RubyMetric/chsrc/issues
458-
- https://github.com/RubyMetric/chsrc/issues
459-
460-
Latest Mirror site status wiki:
461-
462-
- https://github.com/RubyMetric/chsrc/wiki
463-
)");
364+
print (RAWSTR_chsrc_for_issue);
464365

465366
/*
466367
if (chsrc_check_program ("gh"))

0 commit comments

Comments
 (0)