Skip to content

Commit

Permalink
Be more consistent when choosing option strings - found in #104
Browse files Browse the repository at this point in the history
  • Loading branch information
brentvollebregt committed Jun 10, 2020
1 parent a004728 commit 7cd6373
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 2 additions & 3 deletions auto_py_to_exe/web/js/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,12 @@ const getCurrentCommand = () => {
// For switches, there are some switches for false switches that we can use
const potentialOption = options.find(o => o.dest === c.optionDest && o.const === c.value);
if (potentialOption !== undefined) {
// If there's only one potential flag, use it, otherwise use the second one
return potentialOption.option_strings[potentialOption.option_strings.length === 1 ? 0 : 1];
return chooseOptionString(potentialOption.option_strings);
} else {
return null; // If there is no alternate option, skip it as it won't be required
}
} else {
const optionFlag = option.option_strings[option.option_strings.length - 1];
const optionFlag = chooseOptionString(option.option_strings);
return `${optionFlag} "${c.value}"`;
}
}).filter(x => x !== null);
Expand Down
2 changes: 1 addition & 1 deletion auto_py_to_exe/web/js/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const _createSubSectionInAdvanced = (title, options) => {
// Option title / name
const optionNode = document.createElement('span');
container.appendChild(optionNode);
optionNode.textContent = o.option_strings[o.option_strings.length - 1];
optionNode.textContent = chooseOptionString(o.option_strings);

// Help icon
const helpNode = document.createElement('span');
Expand Down
8 changes: 8 additions & 0 deletions auto_py_to_exe/web/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,11 @@ const askForFiles = async () => {
const askForFolder = async () => {
return await eel.ask_folder()();
};

const chooseOptionString = (optionStrings) => {
// Try not to use compressed flags
if (optionStrings[0].length === 2 && optionStrings.length > 1) {
return optionStrings[1];
}
return optionStrings[0];
};

0 comments on commit 7cd6373

Please sign in to comment.