Allow /theme command to return current theme - Add empty args to return theme name on /theme call - Improve help string docs for /theme

c2e6903b303fa99bd427c289fe353c2012ae050c

Wolfsblvt <wolfsblvt@gmail.com>

1 files changed, +30 -7Showing whitespace changes
public/scripts/power-user.js+30 -7
@@ -2968,7 +2968,13 @@ function setAvgBG() {
29682968 return '';
29692969}
29702970
29712971async function setThemeCallback(_, textthemeName) {
2972+ if (!themeName) {
2973+ // allow reporting of the theme name if called without args
2974+ // for use in ST Scripts via pipe
2975+ return power_user.theme;
2976+ }
2977+
29722978 // @ts-ignore
29732979 const fuse = new Fuse(themes, {
29742980 keys: [
@@ -2976,12 +2982,12 @@ async function setThemeCallback(_, text) {
29762982 ],
29772983 });
29782984
29792985 const results = fuse.search(textthemeName);
29802986 console.debug('Theme fuzzy search results for ' + textthemeName, results);
29812987 const theme = results[0]?.item;
29822988
29832989 if (!theme) {
29842990 toastr.warning(`Could not find theme with name: ${textthemeName}`);
29852991 return;
29862992 }
29872993
@@ -4056,13 +4062,30 @@ $(document).ready(() => {
40564062 callback: setThemeCallback,
40574063 unnamedArgumentList: [
40584064 SlashCommandArgument.fromProps({
40594065 description: 'theme name',
40604066 typeList: [ARGUMENT_TYPE.STRING],
4061- isRequired: true,
40624067 enumProvider: () => themes.map(theme => new SlashCommandEnumValue(theme.name)),
40634068 }),
40644069 ],
4065- helpString: 'sets a UI theme by name',
4070+ helpString: `
4071+ <div>
4072+ Sets a UI theme by name.
4073+ </div>
4074+ <div>
4075+ If no theme name is is provided, this will return the currently active theme.
4076+ </div>
4077+ <div>
4078+ <strong>Example:</strong>
4079+ <ul>
4080+ <li>
4081+ <pre><code>/theme Cappuccino</code></pre>
4082+ </li>
4083+ <li>
4084+ <pre><code>/theme</code></pre>
4085+ </li>
4086+ </ul>
4087+ </div>
4088+ `,
40664089 }));
40674090 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
40684091 name: 'movingui',