Displaying multiline data correctly in _ynh_app_config_show #2076
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The problem
As of YNH 12.1.3, if a custom getter in an app returns a multiline string, it will eventually get displayed in the config panel input box (e.g. in text box) as a single line string.
Solution
The proposed solution here is to change
echo
toecho -e
in_ynh_app_config_show()
helper so that it allows interpretation for newline characters.Thus, multiline string output by the custom getter should be as such:
line1\n\nline2\n\nline3
(single newline character is not enough, likely due to other layers of code (not investigated in this PR but which remind me of YunoHost/issues#2501).That way it will get displayed in the config panel (tested for
text
input only) as:PR Status
Ready to merge as I don't believe it could impact negatively other custom getters.
Note that I am not very sure of when is actually triggered the portion of the modified helper after
else
instruction, maybe double newline would be too much here.TODO: update the doc depending on whether that PR is accepted: https://doc.yunohost.org/en/packaging_config_panels
How to test
Cf. custom getter for
marl_ynh
config panel: https://github.com/YunoHost-Apps/marl_ynh/blob/31fbaad1c035630ed541361975c8af4d09025b8b/scripts/config#L76You can install the app and then run
yunohost app config get marl --full --debug
to see whether YAML output includes multiline or singleline entry forarchives_paths
parameter.