Added support for -y - #2553
Conversation
??? They don't need confirm. Also, |
|
Fixed the typo, sorry. It is basically confirmation-less mode feature. Its a global switch, should work for all read calls wherever needed. Since your original code already has default handling if the string is empty, this works quite nicely. |
|
Convert this to a draft if this is still a draft. Later, I want involve other cooperators to review this. Thanks. |
|
OK, its ready for review. |
|
Please @fiftydinar @cheack @Samueru-sama want to review this? |
| printf $"Zsh completion requires editing the main configuration file, but it may cause problems.\nSee https://github.com/ivan-hc/AM/issues/1843\n" | _fit | ||
| read -r -p $"Want to proceed anyway? (y,N)" response | ||
| if echo "$response" | grep -qi "^y"; then | ||
| _read $"Want to proceed anyway? (y,N)" yn |
There was a problem hiding this comment.
the variable name has to be yn for the _read function to automatically give Y:
if [[ "$default_yes" == true ]]; then
# If variable name is 'yn', default to 'y'
if [[ "$var_name" == "yn" ]]; then
results="y"
fi
else
read -r -ep "$prompt" results
fi
|
@vishnu350 by merging #2565 I have added conflicts |
|
Merge and made cleanups, please check. Just search for "_read " or "read -" to find the changed lines. The _read function to wrapper does the following:
It works nicely since AM has a default handling for empty strings, for example: will use date+time if response is an empty string. |
|
All .po files got updated. In case of changes while reviewing, these files may be updated too and cause conflicts again. Please disable workflows in your fork. |
|
Out of these, there are three references to "Type a number and press ENTER:" I made translatable in #2573 |
|
Should I close and redo? The web-flow has made a mess. |
1. Updated parsing to check for -y and then use "shift" to remove it. 2. Added a _read function to wrap the actual read function: - Provides a default "Y" if the read variable name is $yn. - Provides a default "1" if the read variable name is $choice. - Provides a default "" (empty string) if variable name is anything else.
|
I'm going to merge this to the dev branch, so people can test it using This will be the core change in AM 10.4 |
This is a PR for AM with support for -y. Just add '-y' as the first command, it will auto-choose "Y" for Y/N questions, or an empty string for the others.
Echo will no longer be needed for using am/appman inside scripts, it will behave more closely like existing distro package managers (eg.
apt -y ...).Methodology:
_readfunction to wrap the actualreadfunction:Example usage:
am -y -r appam -y --useram -y lock appam -y --translateam -yorappman -y