Skip to content

Commit

Permalink
Settings: display message when updating current settings
Browse files Browse the repository at this point in the history
  • Loading branch information
themitosan committed Jan 2, 2025
1 parent 9bdeba4 commit f5c5651
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
4 changes: 3 additions & 1 deletion Lang/pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"unableGetNpmRootPath": "ERRO - Não foi possível obter o local de instalação global do NPM!\nMotivo: %VAR_0%",
"unableGetNpmRootPath_notFound": "Caminho não encontrado! (%VAR_0%)",

"warnRepoNotFound": "AVISO - Não foi possível encontrar %VAR_0% no banco de dados!"
"warnRepoNotFound": "AVISO - Não foi possível encontrar %VAR_0% no banco de dados!",

"saveSettings": "AVISO - Salvando alterações..."

},

Expand Down
4 changes: 3 additions & 1 deletion src/lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export var langDatabase:any = {
"unableGetNpmRootPath": "ERROR - Unable to get NPM root path!\nReason: %VAR_0%",
"unableGetNpmRootPath_notFound": "Path not found! (%VAR_0%)",

"warnRepoNotFound": "WARN - Unable to find %VAR_0% on repo database!"
"warnRepoNotFound": "WARN - Unable to find %VAR_0% on repo database!",

"saveSettings": "INFO - Saving settings..."

},

Expand Down
24 changes: 16 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,14 @@ async function grpp_loadSettings(){
/**
* Save GRPP settings
* @param mode [string] Which settings file should be updated (Default: grpp_settings)
* @param displayLog [boolean] Set true to display saving message on screen
*/
export async function grpp_saveSettings(mode:string = 'db'){
export async function grpp_saveSettings(mode:string = 'db', displayLog:boolean = !1){
try {

// Swicth save mode
process.chdir(originalCwd);
if (displayLog === !0) createLogEntry(langDatabase.main.saveSettings);
switch (mode){

// User settings
Expand Down Expand Up @@ -365,8 +367,14 @@ async function init(){
*/
for (var i = 0; i < process.argv.length; i++){

// Get current flag and check if current flag is grpp call
const currentArg = getArgName(process.argv[i]);
// Create consts
const
currentArg = getArgName(process.argv[i]),
saveSettings = function(){
grpp_saveSettings('user', !0);
};

// Check if current flag is grpp call
if (process.argv[i].indexOf('/grpp') !== -1 && i < (process.argv.length - 1)) grppCmdIndex = i;

// Check if needs to enable silent mode
Expand All @@ -378,7 +386,7 @@ async function init(){
// Set max repos a batch file should have
if (currentArg.indexOf('maxReposPerList=') !== -1){
tempSettings.maxReposPerList = preventMinMax(Math.floor(Number(currentArg.replace('maxReposPerList=', ''))), 1, maxValue);
execFn = grpp_saveSettings;
execFn = saveSettings;
}

// User settings: Set lang
Expand All @@ -387,25 +395,25 @@ async function init(){
// Set max fetch pages
if (currentArg.indexOf('setMaxFetchPages=') !== -1){
tempSettings.maxPages = preventMinMax(Math.floor(Number(currentArg.replace('setMaxFetchPages=', ''))), 1, maxValue);
execFn = grpp_saveSettings;
execFn = saveSettings;
}

// Set web test url
if (currentArg.indexOf('setConnectionTestURL=') !== -1){
tempSettings.connectionTestURL = currentArg.replace('setConnectionTestURL=', '');
execFn = grpp_saveSettings;
execFn = saveSettings;
}

// Set starting fetch page
if (currentArg.indexOf('setStartPage=') !== -1){
tempSettings.fetchStartPage = preventMinMax(Math.floor(Number(currentArg.replace('setStartPage=', ''))), 0, maxValue);
execFn = grpp_saveSettings;
execFn = saveSettings;
}

// Set text editor
if (currentArg.indexOf('setEditor') !== -1){
tempSettings.userEditor = currentArg.replace('setEditor=', '');
execFn = grpp_saveSettings;
execFn = saveSettings;
}

// Set GRPP path
Expand Down

0 comments on commit f5c5651

Please sign in to comment.