Add rawQuotes to override with named arg (#4032)
Signed| @@ -266,6 +266,14 @@ export function initDefaultSlashCommands() { | ||
| 266 | 266 | enumList: slashCommandReturnHelper.enumList({ allowObject: true }), |
| 267 | 267 | forceEnum: true, |
| 268 | 268 | }), |
| 269 | + SlashCommandNamedArgument.fromProps({ | |
| 270 | + name: 'raw', | |
| 271 | + description: 'If true, does not alter quoted literal unnamed arguments', | |
| 272 | + typeList: [ARGUMENT_TYPE.BOOLEAN], | |
| 273 | + defaultValue: 'true', | |
| 274 | + enumProvider: commonEnumProviders.boolean('trueFalse'), | |
| 275 | + isRequired: false, | |
| 276 | + }), | |
| 269 | 277 | ], |
| 270 | 278 | unnamedArgumentList: [ |
| 271 | 279 | new SlashCommandArgument( |
| @@ -328,6 +336,14 @@ export function initDefaultSlashCommands() { | ||
| 328 | 336 | enumList: slashCommandReturnHelper.enumList({ allowObject: true }), |
| 329 | 337 | forceEnum: true, |
| 330 | 338 | }), |
| 339 | + SlashCommandNamedArgument.fromProps({ | |
| 340 | + name: 'raw', | |
| 341 | + description: 'If true, does not alter quoted literal unnamed arguments', | |
| 342 | + typeList: [ARGUMENT_TYPE.BOOLEAN], | |
| 343 | + defaultValue: 'true', | |
| 344 | + enumProvider: commonEnumProviders.boolean('trueFalse'), | |
| 345 | + isRequired: false, | |
| 346 | + }), | |
| 331 | 347 | ], |
| 332 | 348 | unnamedArgumentList: [ |
| 333 | 349 | new SlashCommandArgument( |
| @@ -392,6 +408,14 @@ export function initDefaultSlashCommands() { | ||
| 392 | 408 | enumList: slashCommandReturnHelper.enumList({ allowObject: true }), |
| 393 | 409 | forceEnum: true, |
| 394 | 410 | }), |
| 411 | + SlashCommandNamedArgument.fromProps({ | |
| 412 | + name: 'raw', | |
| 413 | + description: 'If true, does not alter quoted literal unnamed arguments', | |
| 414 | + typeList: [ARGUMENT_TYPE.BOOLEAN], | |
| 415 | + defaultValue: 'true', | |
| 416 | + enumProvider: commonEnumProviders.boolean('trueFalse'), | |
| 417 | + isRequired: false, | |
| 418 | + }), | |
| 395 | 419 | ], |
| 396 | 420 | unnamedArgumentList: [ |
| 397 | 421 | new SlashCommandArgument( |
| @@ -617,6 +641,14 @@ export function initDefaultSlashCommands() { | ||
| 617 | 641 | enumList: slashCommandReturnHelper.enumList({ allowObject: true }), |
| 618 | 642 | forceEnum: true, |
| 619 | 643 | }), |
| 644 | + SlashCommandNamedArgument.fromProps({ | |
| 645 | + name: 'raw', | |
| 646 | + description: 'If true, does not alter quoted literal unnamed arguments', | |
| 647 | + typeList: [ARGUMENT_TYPE.BOOLEAN], | |
| 648 | + defaultValue: 'true', | |
| 649 | + enumProvider: commonEnumProviders.boolean('trueFalse'), | |
| 650 | + isRequired: false, | |
| 651 | + }), | |
| 620 | 652 | ], |
| 621 | 653 | unnamedArgumentList: [ |
| 622 | 654 | new SlashCommandArgument( |
| @@ -1013,6 +1045,14 @@ export function initDefaultSlashCommands() { | ||
| 1013 | 1045 | description: 'a closure to call when the toast is clicked. This executed closure receives scope as provided in the script. Careful about possible side effects when manipulating variables and more.', |
| 1014 | 1046 | typeList: [ARGUMENT_TYPE.CLOSURE], |
| 1015 | 1047 | }), |
| 1048 | + SlashCommandNamedArgument.fromProps({ | |
| 1049 | + name: 'raw', | |
| 1050 | + description: 'If true, does not alter quoted literal unnamed arguments', | |
| 1051 | + typeList: [ARGUMENT_TYPE.BOOLEAN], | |
| 1052 | + defaultValue: 'true', | |
| 1053 | + enumProvider: commonEnumProviders.boolean('trueFalse'), | |
| 1054 | + isRequired: false, | |
| 1055 | + }), | |
| 1016 | 1056 | ], |
| 1017 | 1057 | unnamedArgumentList: [ |
| 1018 | 1058 | new SlashCommandArgument( |
| @@ -266,7 +266,7 @@ export class SlashCommand { | ||
| 266 | 266 | rawQuotes.classList.add('rawQuotes'); |
| 267 | 267 | rawQuotes.classList.add('fa-solid'); |
| 268 | 268 | rawQuotes.classList.add('fa-quote-left'); |
| 269 | 269 | rawQuotes.title = t`Does not alter quoted literal unnamed arguments. Pass raw=false argument to override.`; |
| 270 | 270 | head.append(rawQuotes); |
| 271 | 271 | } |
| 272 | 272 | } |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | import { hljs } from '../../lib.js'; |
| 2 | 2 | import { power_user } from '../power-user.js'; |
| 3 | 3 | import { isFalseBoolean, isTrueBoolean, uuidv4 } from '../utils.js'; |
| 4 | 4 | import { SlashCommand } from './SlashCommand.js'; |
| 5 | 5 | import { ARGUMENT_TYPE, SlashCommandArgument } from './SlashCommandArgument.js'; |
| 6 | 6 | import { SlashCommandClosure } from './SlashCommandClosure.js'; |
| @@ -975,7 +975,9 @@ export class SlashCommandParser { | ||
| 975 | 975 | cmd.startUnnamedArgs = this.index - (/\s(\s*)$/s.exec(this.behind)?.[1]?.length ?? 0); |
| 976 | 976 | cmd.endUnnamedArgs = this.index; |
| 977 | 977 | if (this.testUnnamedArgument()) { |
| 978 | - cmd.unnamedArgumentList = this.parseUnnamedArgument(cmd.command?.unnamedArgumentList?.length && cmd?.command?.splitUnnamedArgument, cmd?.command?.splitUnnamedArgumentCount, cmd?.command?.rawQuotes); | |
| 978 | + const rawQuotesArg = cmd?.namedArgumentList?.find(a => a.name === 'raw'); | |
| 979 | + const rawQuotes = cmd?.command?.rawQuotes && rawQuotesArg ? !isFalseBoolean(rawQuotesArg?.value?.toString()) : cmd?.command?.rawQuotes; | |
| 980 | + cmd.unnamedArgumentList = this.parseUnnamedArgument(cmd.command?.unnamedArgumentList?.length && cmd?.command?.splitUnnamedArgument, cmd?.command?.splitUnnamedArgumentCount, rawQuotes); | |
| 979 | 981 | cmd.endUnnamedArgs = this.index; |
| 980 | 982 | if (cmd.name == 'let') { |
| 981 | 983 | const keyArg = cmd.namedArgumentList.find(it=>it.name == 'key'); |