mirror of
https://github.com/RubyMetric/chsrc
synced 2025-06-28 23:42:49 +08:00
Update help
This commit is contained in:
parent
f0abe510d1
commit
30fa50ba33
43
chsrc.c
43
chsrc.c
@ -22,23 +22,25 @@
|
|||||||
* 参考:https://mirrors.tuna.tsinghua.edu.cn/help/pypi/
|
* 参考:https://mirrors.tuna.tsinghua.edu.cn/help/pypi/
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
pl_python_chsrc (char* source_name)
|
pl_python_chsrc (char* option)
|
||||||
{
|
{
|
||||||
char* source_url = NULL;
|
int selected = 0;
|
||||||
|
|
||||||
if (NULL==source_name) {
|
for (int i=0;i<sizeof(pl_ruby_sources);i++) {
|
||||||
source_name = "tuna";
|
// 循环测速
|
||||||
puts("chsrc: Default selection is TsingHua Tuna");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0==strcmp("tuna", source_name)) {
|
const char* source_name = pl_ruby_sources[selected].mirror->name;
|
||||||
puts("chsrc: Selected source provider: Tuna");
|
const char* source_abbr = pl_ruby_sources[selected].mirror->abbr;
|
||||||
source_url = "https://pypi.tuna.tsinghua.edu.cn/simple";
|
const char* source_url = pl_ruby_sources[selected].url;
|
||||||
}
|
|
||||||
|
xy_info (xy_strjoin("chsrc: 选中镜像站:", source_abbr));
|
||||||
|
|
||||||
char* cmd = xy_strjoin("pip config set global.index-url ", source_url);
|
char* cmd = xy_strjoin("pip config set global.index-url ", source_url);
|
||||||
system(cmd);
|
system(cmd);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
|
|
||||||
|
xy_success(xy_strjoin("chsrc: 感谢镜像提供方:", source_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -59,9 +61,9 @@ pl_ruby_chsrc (char* option)
|
|||||||
const char* source_abbr = pl_ruby_sources[selected].mirror->abbr;
|
const char* source_abbr = pl_ruby_sources[selected].mirror->abbr;
|
||||||
const char* source_url = pl_ruby_sources[selected].url;
|
const char* source_url = pl_ruby_sources[selected].url;
|
||||||
|
|
||||||
puts (xy_strjoin("chsrc: 选中镜像站:", source_abbr));
|
xy_info (xy_strjoin("chsrc: 选中镜像站:", source_abbr));
|
||||||
|
|
||||||
puts("chsrc: 为'gem'命令换源");
|
xy_info("chsrc: 为 gem 命令换源");
|
||||||
system("gem source -r https://rubygems.org/");
|
system("gem source -r https://rubygems.org/");
|
||||||
|
|
||||||
char* cmd = xy_strjoin("gem source -a ", source_url);
|
char* cmd = xy_strjoin("gem source -a ", source_url);
|
||||||
@ -69,11 +71,11 @@ pl_ruby_chsrc (char* option)
|
|||||||
free(cmd);
|
free(cmd);
|
||||||
|
|
||||||
cmd = xy_strjoin("bundle config 'mirror.https://rubygems.org' ", source_url);
|
cmd = xy_strjoin("bundle config 'mirror.https://rubygems.org' ", source_url);
|
||||||
puts("chsrc: 为'bundler'命令换源");
|
xy_info("chsrc: 为 bundler 命令换源");
|
||||||
system(cmd);
|
system(cmd);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
|
|
||||||
puts(xy_strjoin("chsrc: 感谢镜像提供方:", source_name));
|
xy_success(xy_strjoin("chsrc: 感谢镜像提供方:", source_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define cmdfunc(func) (const char const*)func
|
#define cmdfunc(func) (const char const*)func
|
||||||
@ -101,11 +103,14 @@ static const char const
|
|||||||
static const char const*
|
static const char const*
|
||||||
usage[] = {
|
usage[] = {
|
||||||
"chsrc: Change Source " Chsrc_Version " by RubyMetric\n",
|
"chsrc: Change Source " Chsrc_Version " by RubyMetric\n",
|
||||||
|
|
||||||
|
"维护: https://gitee.com/RubyMetric/chsrc\n",
|
||||||
|
|
||||||
"使用:\n"
|
"使用:\n"
|
||||||
" chsrc <要换源的对象> [所换源名称]\n",
|
" chsrc <要换源的对象> [所换源名称]\n",
|
||||||
|
|
||||||
"选项:\n"
|
"选项:\n"
|
||||||
" -h 打印该帮助\n",
|
" -h, --help 打印该帮助\n",
|
||||||
|
|
||||||
"支持:\n"
|
"支持:\n"
|
||||||
};
|
};
|
||||||
@ -116,7 +121,7 @@ call_cmd (void* cmdptr, const char* arg)
|
|||||||
{
|
{
|
||||||
void (*cmd_func)(const char*) = cmdptr;
|
void (*cmd_func)(const char*) = cmdptr;
|
||||||
if (NULL==arg) {
|
if (NULL==arg) {
|
||||||
puts("chsrc: 将使用默认镜像");
|
xy_info("chsrc: 将使用默认镜像");
|
||||||
}
|
}
|
||||||
cmd_func(arg);
|
cmd_func(arg);
|
||||||
}
|
}
|
||||||
@ -126,7 +131,7 @@ int
|
|||||||
print_help ()
|
print_help ()
|
||||||
{
|
{
|
||||||
for (int i=0; i<Array_Size(usage); i++) {
|
for (int i=0; i<Array_Size(usage); i++) {
|
||||||
puts(usage[i]);
|
xy_info(usage[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +148,7 @@ main (int argc, char const *argv[])
|
|||||||
|
|
||||||
// 第一个参数
|
// 第一个参数
|
||||||
const char* target = NULL;
|
const char* target = NULL;
|
||||||
if (0==strcmp("-h",argv[1])) {
|
if (0==strcmp("-h",argv[1]) || 0==strcmp("--help",argv[1])) {
|
||||||
print_help(); return 0;
|
print_help(); return 0;
|
||||||
} else {
|
} else {
|
||||||
target = argv[1];
|
target = argv[1];
|
||||||
@ -185,7 +190,7 @@ main (int argc, char const *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!matched) {
|
if (!matched) {
|
||||||
puts("chsrc: 暂不支持的换源类型,请使用-h查看可换源");
|
xy_info("chsrc: 暂不支持的换源类型,请使用-h查看可换源");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user