Secure command options

Some macro commands, usually those performing protected actions, can have their arguments specified using the secure command options syntax. This allows a limited range of information, expressed using macro conditionals, to be used to automate decision making. For example, you can create a macro to cast a :heal if your current target is friendly, or a nuke if your current target is hostile.
Secure command options can also be used by addons, including within the RestrictedEnvironment, and by the SecureStateDriver API.
== Syntax ==
A secure command options string consists of one or more clauses delimited by semicolons. Each clause consists of zero or more conditions (if no conditions are specified, the clause is considered to have a single, empty condition), and an arbitrary string value, which may not contain the []; characters. Each condition, enclosed in square brackets, contains zero or more macro conditionals, separated by commas. A condition is considered satisfied if all of its conditionals are satisfied; [], containing no conditionals, is always considered satisfied. Conditions are evaluated in order, stopping at the first satisfied condition, returning the associated clause value and the conditional target (if specified in the condition). If no conditions are satisfied, no value is returned when evaluating the options string.
The interpretation of the returned clause value and condition target depends on the context in which the secure command options are used -- different macro commands may interpret the clause value and conditional target differently, or ignore one or both.
Below are some examples of macro commands using secure command options:
* /cast [@mouseover,harm][harm] Moonfire; [@mouseover,help][@focus,help,nodead][@player,mod:alt] Regrowth; Rejuvenation
** There are a total of three clauses and six conditions (one of which is implicit); the first satisfied condition determines what action is performed and at which target:
**# [@mouseover,harm]: if the mouse cursor is hovering over a hostile unit, Moonfire will be cast at that hostile unit.
**# [harm]: if your current target is hostile, Moonfire will be cast at your target.
**# [@mouseover,help]: if the mouse cursor is hovering over a friendly unit, Regrowth will be cast at that friendly unit.
**# [@focus,help,nodead]: if your focus target is a friendly and still alive, Regrowth will be cast at your focus target.
**# [@player,mod:alt]: if you are holding down the ALT key, Regrowth will be cast at your character.
**# [] (implied by the lack of conditions in ; Rejuvenation): otherwise (always) attempt to cast Rejuvenation. The exact target depends on your current target and interface options: if you have a friendly target, Rejuvenation will be cast at it; otherwise, you may see a spell targetting cursor, or cast Rejuvenation on yourself.
* /stopcasting [mod:alt]
** Stops the current spell cast if you're holding down the ALT key. Otherwise, no action is performed. /stopcasting explicitly ignores the returned clause value and condition target.
* /focus [@mouseover,mod:alt][]
** Focuses the unit your mouse cursor is hovering over if ALT is being held down, and your current target otherwise.
* /target [@focus,help][] player
** Targets your focus target if it is friendly, and targets the player otherwise. Although the player clause value is also returned in the first case, /target ignores it in favor of the specified condition target.
== See also ==
* Macro conditionals
* Making a macro
* 
 Secure command options