Refactor target group mode

This commit is contained in:
Aoran Zeng
2025-07-11 10:12:27 +08:00
parent 8b9c0b565b
commit e953aceb54
9 changed files with 69 additions and 42 deletions

View File

@@ -74,7 +74,7 @@ pl_nodejs_setsrc (char *option)
bool npm_exist, yarn_exist, pnpm_exist;
pl_nodejs_check_cmd (&npm_exist, &yarn_exist, &pnpm_exist);
ProgMode_Target_Group = true;
chsrc_set_target_group_mode ();
chsrc_yield_source_and_confirm (pl_nodejs);
if (npm_exist)

View File

@@ -42,7 +42,7 @@ pl_nodejs_yarn_setsrc (char *option)
{
Source_t source;
chsrc_yield_for_the_source (pl_nodejs);
if (ProgMode_Target_Group!=true)
if (!chsrc_in_target_group_mode())
chsrc_confirm_source;
char *cmd = NULL;
@@ -71,7 +71,7 @@ pl_nodejs_yarn_setsrc (char *option)
chsrc_run (cmd, RunOpt_No_Last_New_Line);
}
if (ProgMode_Target_Group!=true)
if (!chsrc_in_target_group_mode())
{
chsrc_determine_chgtype (ChgType_Auto);
chsrc_conclude (&source);

View File

@@ -28,7 +28,7 @@ pl_nodejs_npm_setsrc (char *option)
{
Source_t source;
chsrc_yield_for_the_source (pl_nodejs);
if (ProgMode_Target_Group!=true)
if (!chsrc_in_target_group_mode())
chsrc_confirm_source;
char *cmd = NULL;
@@ -40,7 +40,7 @@ pl_nodejs_npm_setsrc (char *option)
chsrc_run (cmd, RunOpt_No_Last_New_Line);
if (ProgMode_Target_Group!=true)
if (!chsrc_in_target_group_mode())
{
chsrc_determine_chgtype (ChgType_Auto);
chsrc_conclude (&source);

View File

@@ -29,7 +29,7 @@ pl_nodejs_pnpm_setsrc (char *option)
{
Source_t source;
chsrc_yield_for_the_source (pl_nodejs);
if (ProgMode_Target_Group!=true)
if (!chsrc_in_target_group_mode())
chsrc_confirm_source;
char *cmd = NULL;
@@ -41,7 +41,7 @@ pl_nodejs_pnpm_setsrc (char *option)
chsrc_run (cmd, RunOpt_No_Last_New_Line);
if (ProgMode_Target_Group!=true)
if (!chsrc_in_target_group_mode())
{
chsrc_determine_chgtype (ChgType_Auto);
chsrc_conclude (&source);

View File

@@ -30,7 +30,7 @@ pl_python_pdm_setsrc (char *option)
{
Source_t source;
chsrc_yield_for_the_source (pl_python);
if (ProgMode_Target_Group!=true)
if (!chsrc_in_target_group_mode())
chsrc_confirm_source;
char *cmd = NULL;
@@ -42,7 +42,7 @@ pl_python_pdm_setsrc (char *option)
chsrc_run (cmd, RunOpt_No_Last_New_Line);
if (ProgMode_Target_Group!=true)
if (!chsrc_in_target_group_mode())
{
chsrc_determine_chgtype (ChgType_Auto);
chsrc_conclude (&source);

View File

@@ -29,7 +29,7 @@ pl_python_poetry_setsrc (char *option)
{
Source_t source;
chsrc_yield_for_the_source (pl_python);
if (ProgMode_Target_Group!=true)
if (!chsrc_in_target_group_mode())
chsrc_confirm_source;
char *cmd = NULL;
@@ -40,7 +40,7 @@ pl_python_poetry_setsrc (char *option)
cmd = xy_2strjoin ("poetry source add my_mirror ", source.url);
chsrc_run (cmd, RunOpt_No_Last_New_Line);
if (ProgMode_Target_Group!=true)
if (!chsrc_in_target_group_mode())
{
chsrc_determine_chgtype (ChgType_Auto);
chsrc_conclude (&source);

View File

@@ -57,7 +57,7 @@ pl_python_setsrc (char *option)
pl_python_check_unofficial_pkger (&poetry_exist, &pdm_exist, &uv_exist);
ProgMode_Target_Group = true;
chsrc_set_target_group_mode ();
chsrc_yield_source_and_confirm (pl_python);

View File

@@ -40,7 +40,7 @@ pl_python_pip_setsrc (char *option)
Source_t source;
chsrc_yield_for_the_source (pl_python);
if (ProgMode_Target_Group!=true)
if (!chsrc_in_target_group_mode())
chsrc_confirm_source;
char *py_prog_name = NULL;
@@ -52,7 +52,7 @@ pl_python_pip_setsrc (char *option)
char *cmd = xy_2strjoin (py_prog_name, xy_2strjoin (" -m pip config --user set global.index-url ", source.url));
chsrc_run (cmd, RunOpt_No_Last_New_Line);
if (ProgMode_Target_Group!=true)
if (!chsrc_in_target_group_mode())
{
chsrc_determine_chgtype (ChgType_Auto);
chsrc_conclude (&source);