Add support for r

This commit is contained in:
Aoran Zeng 2023-09-04 20:27:37 +08:00
parent e9b262e521
commit b9c57d54d2
3 changed files with 17 additions and 9 deletions

View File

@ -1,6 +1,6 @@
# chsrc
全平台命令行换源工具,**目标支持 Linux, Windows, macOS, BSD 等所有操作系统,飞腾,龙芯等所有CPU**。
全平台命令行换源工具,**目标支持 Linux, Windows, macOS, BSD 等所有操作系统,龙芯、申威、飞腾、兆芯、海光等所有CPU**。
若有不支持的情况请提交issue。
@ -41,7 +41,7 @@ set <target> <mirror> # 换源,指定使用某镜像站
- [ ] `chsrc set rust``chsrc set cargo``chsrc crate`
- [ ] `chsrc set java``chsrc set maven``chsrc set mvn``chsrc gradle`
- [ ] `chsrc set r``chsrc set cran`
- [x] `chsrc set r``chsrc set cran`
- [ ] `chsrc set julia`
## 操作系统

19
chsrc.c
View File

@ -627,16 +627,23 @@ pl_java_setsrc (char* option)
}
/* TODO: 暂未实现 */
void
pl_r_getsrc (char* option)
{
// char* cmd = "npm config get registry";
// system(cmd);
char* cmd = NULL;
if(xy_on_windows) {
cmd = "type %USERPROFILE%\\Documents\\.Rprofile";
} else {
cmd = "cat ~/.Rprofile";
}
chsrc_logcmd(cmd);
system(cmd);
}
/**
* R https://help.mirrors.cernet.edu.cn/CRAN/
* TODO: bioconductor
*/
void
pl_r_setsrc (char* option)
@ -655,12 +662,12 @@ pl_r_setsrc (char* option)
const char* file = xy_strjoin (3, "options(\"repos\" = c(CRAN=\"", source.url, "\"))" );
char* cmd = NULL;
// TODO: 待确认Windows 下是否也是该文件
if (xy_on_windows)
cmd = xy_strjoin(3, "echo ", file, " >> %USERPROFILE%/.Rprofile");
cmd = xy_strjoin(3, "echo ", file, " >> %USERPROFILE%/Documents/.Rprofile");
else
cmd = xy_strjoin(3, "echo ", file, " >> ~/.Rprofile");
chsrc_logcmd(cmd);
system(cmd);
chsrc_say_thanks(&source);
}
@ -931,7 +938,7 @@ target_info
pl_dotnet_target = {pl_dotnet_setsrc, NULL, pl_dotnet_sources, pl_dotnet_sources_n},
pl_java_target = {pl_java_setsrc, NULL, pl_java_sources, pl_java_sources_n},
pl_php_target = {pl_php_setsrc, pl_php_getsrc, pl_php_sources, pl_php_sources_n},
pl_r_target = {pl_r_setsrc, NULL, pl_r_sources, pl_r_sources_n},
pl_r_target = {pl_r_setsrc, pl_r_getsrc, pl_r_sources, pl_r_sources_n},
pl_julia_target = {pl_julia_setsrc, NULL, pl_julia_sources, pl_julia_sources_n};

View File

@ -189,7 +189,7 @@ pl_perl_sources[] = {
/**
* 2023-08-30
* 2023-09-04
*
* TODO: R用户协助
*/
@ -197,6 +197,7 @@ pl_r_sources[] = {
{&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/cran/"},
{&Ali, "https://mirrors.aliyun.com/CRAN/"},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/CRAN/"},
{&Sustech, "https://mirrors.sustech.edu.cn/CRAN"},
{&Bfsu, "https://mirrors.bfsu.edu.cn/CRAN/"},
{&Bjtu, "https://mirror.bjtu.edu.cn/cran/"},
},