Enumerations

Enumerations define a named set of accepted string values for use in action parameters.

Table of contents

  1. Syntax
  2. Using enums in action definitions
  3. Standard library enums

Syntax

enum typeName {
    'Option1',
    'Option2'
}

Each value is raw text (single quoted string). A trailing comma after the last value is allowed.

Using enums in action definitions

Enums are used as parameter types in action definitions. When an action parameter has an enum type, only the declared values are accepted.

enum hashType {
    'MD5',
    'SHA1',
    'SHA256',
    'SHA512',
}

action 'is.workflow.actions.hash' hash(variable input, hashAlgorithm ?algorithm = "MD5")

Calling the action with an enum value:

#include 'actions/crypto'

@input = "Hello, Cherri!"
const result = hash(@input, "SHA256")

Standard library enums

The standard library action pages show the enum definition inline alongside each action that uses one. These enums are defined inside the Cherri compiler - you do not need to define them yourself when using standard library actions.

For example, from the Crypto actions:

enum hashType {
    'MD5',
    'SHA1',
    'SHA256',
    'SHA512',
}

hash(variable input, hashAlgorithm ?algorithm = "MD5")

When calling hash(), pass one of the declared string values as the argument.


Copyright ©. Distributed under the GPL-2.0 License. Siri Shortcuts and Mac are registered trademarks of Apple Inc. Apple is not involved in this project in any way. Do not contact Apple Support unless you are having an issue with the Shortcuts app itself.