mirror of
https://github.com/RubyMetric/chsrc
synced 2025-09-07 07:04:41 +08:00
重命名为 xy_quiet_cmd()
This commit is contained in:
parent
cf07b13776
commit
9f52a4d2be
35
lib/xy.h
35
lib/xy.h
@ -491,19 +491,6 @@ xy_streql_ic(const char *str1, const char *str2)
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
xy_str_to_quietcmd (const char *cmd)
|
||||
{
|
||||
char *ret = NULL;
|
||||
#ifdef _WIN32
|
||||
ret = xy_2strcat (cmd, " >nul 2>nul ");
|
||||
#else
|
||||
ret = xy_2strcat (cmd, " 1>/dev/null 2>&1 ");
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @flavor Ruby: String#end_with?
|
||||
*/
|
||||
@ -776,9 +763,23 @@ _xy_log_brkt (int level, const char *prompt1, const char *prompt2, const char *c
|
||||
|
||||
|
||||
/******************************************************
|
||||
* System
|
||||
* cross OS
|
||||
******************************************************/
|
||||
|
||||
static char *
|
||||
xy_quiet_cmd (const char *cmd)
|
||||
{
|
||||
char *ret = NULL;
|
||||
|
||||
if (xy.on_windows)
|
||||
ret = xy_2strcat (cmd, " >nul 2>nul ");
|
||||
else
|
||||
ret = xy_2strcat (cmd, " 1>/dev/null 2>&1 ");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 执行 `cmd`,返回某行输出结果,并对已经遍历过的行执行 `func`
|
||||
*
|
||||
@ -845,7 +846,7 @@ xy_run (const char *cmd, unsigned long n)
|
||||
int
|
||||
xy_run_get_status (char *cmd)
|
||||
{
|
||||
char * command = xy_str_to_quietcmd (cmd);
|
||||
char * command = xy_quiet_cmd (cmd);
|
||||
|
||||
int status = system (command);
|
||||
return status;
|
||||
@ -896,10 +897,6 @@ xy_run_get_stdout (const char *cmd, char **output)
|
||||
}
|
||||
|
||||
|
||||
/******************************************************
|
||||
* cross OS
|
||||
******************************************************/
|
||||
|
||||
/**
|
||||
* @flavor 该函数同 just 中的 os_family(),只区分 windows, unix
|
||||
*
|
||||
|
@ -443,7 +443,7 @@ cli_print_issues ()
|
||||
/*
|
||||
if (chsrc_check_program ("gh"))
|
||||
{
|
||||
char *cmd = xy_str_to_quietcmd ("gh browse --repo RubyMetric/chsrc");
|
||||
char *cmd = xy_quiet_cmd ("gh browse --repo RubyMetric/chsrc");
|
||||
system (cmd);
|
||||
}
|
||||
*/
|
||||
|
@ -383,7 +383,7 @@ cmd_to_check_program (char *prog_name)
|
||||
{
|
||||
char *check_tool = xy.on_windows ? "where " : "command -v ";
|
||||
|
||||
char *quiet_cmd = xy_str_to_quietcmd (xy_2strcat (check_tool, prog_name));
|
||||
char *quiet_cmd = xy_quiet_cmd (xy_2strcat (check_tool, prog_name));
|
||||
|
||||
return quiet_cmd;
|
||||
}
|
||||
@ -402,7 +402,7 @@ XY_Deprecate_This("Use cmd_to_check_program() instead")
|
||||
static char *
|
||||
cmd_to_check_program2 (char *prog_name)
|
||||
{
|
||||
char *quiet_cmd = xy_str_to_quietcmd (xy_2strcat (prog_name, " --version"));
|
||||
char *quiet_cmd = xy_quiet_cmd (xy_2strcat (prog_name, " --version"));
|
||||
return quiet_cmd;
|
||||
}
|
||||
|
||||
@ -1595,7 +1595,7 @@ chsrc_ensure_dir (const char *dir)
|
||||
mkdir_cmd = "mkdir -p ";
|
||||
}
|
||||
char *cmd = xy_2strcat (mkdir_cmd, dir);
|
||||
cmd = xy_str_to_quietcmd (cmd);
|
||||
cmd = xy_quiet_cmd (cmd);
|
||||
|
||||
chsrc_run_as_a_service (cmd);
|
||||
|
||||
|
@ -53,7 +53,7 @@ pl_go_prelude ()
|
||||
void
|
||||
pl_go_check_cmd ()
|
||||
{
|
||||
char *check_cmd = xy_str_to_quietcmd ("go version");
|
||||
char *check_cmd = xy_quiet_cmd ("go version");
|
||||
bool exist = query_program_exist (check_cmd, "go", Noisy_When_Exist|Noisy_When_NonExist);
|
||||
|
||||
if (!exist)
|
||||
|
@ -78,7 +78,7 @@ pl_js_yarn_setsrc (char *option)
|
||||
// 不能直接退出,因为 Leader target 不能就此结束
|
||||
return;
|
||||
}
|
||||
// 不再阻止换源命令输出到终端,即不再调用 xy_str_to_quietcmd()
|
||||
// 不再阻止换源命令输出到终端,即不再调用 xy_quiet_cmd()
|
||||
cmd = xy_2strcat ("yarn config set registry ", source.url);
|
||||
chsrc_run (cmd, RunOpt_No_Last_New_Line);
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ os_freebsd_setsrc (char *option)
|
||||
// @ccmywish: 2023-09-27 据 @ykla , NJU的freebsd-ports源没有设置 Git,
|
||||
// 但是我认为由于使用Git还是要比非Git方便许多,我们尽可能坚持使用Git
|
||||
// 而 gitup 又要额外修改它自己的配置,比较麻烦
|
||||
bool git_exist = query_program_exist (xy_str_to_quietcmd ("git version"), "git", Noisy_When_Exist|Noisy_When_NonExist);
|
||||
bool git_exist = query_program_exist (xy_quiet_cmd ("git version"), "git", Noisy_When_Exist|Noisy_When_NonExist);
|
||||
if (git_exist)
|
||||
{
|
||||
if (xy_streql("nju",source.mirror->code))
|
||||
|
Loading…
x
Reference in New Issue
Block a user