☁️ Loving our new documentation website? Provide feedback in the CloudCannon Community! ✨

Argument Parser Configuration

Table of contents

Description:

This key defines a parser configuration that parses a single argument, optionally delimited by characters.

Useful for matching a single positional argument.

The argument parser is also used to parse a list of repeating arguments.

Appears in:
└── Snippet
    └── params
        └── *
            └── Argument Parser Configuration
Type:
Object
Properties:
optionsObject Required#

This key defines configuration options for argument parser configurations.

The value is an object that can contain model and format properties. These options control how a single argument value is parsed and validated.

Show examplesHide examples

In this example, we have configured argument parser options with a model and format.

Copied to clipboard
_snippets:
  example:
    snippet: <<example [[param]]>>
    params:
      param:
        parser: argument
        options:
          model:
            editor_key: example_id
          format:
            string_boundary:
              - '"'
{
  "_snippets": {
    "example": {
      "snippet": "<<example [[param]]>>",
      "params": {
        "param": {
          "parser": "argument",
          "options": {
            "model": {
              "editor_key": "example_id"
            },
            "format": {
              "string_boundary": [
                "\""
              ]
            }
          }
        }
      }
    }
  }
}
parser"argument" Required#

This key defines the parser type for argument parser configurations.

The value must be argument. This specifies that the parameter uses the argument parser, which parses a single argument value.

Show examplesHide examples

In this example, we have configured an argument parser for a snippet parameter.

Copied to clipboard
_snippets:
  example:
    snippet: <<example [[param]]>>
    params:
      param:
        parser: argument
        options:
          model:
            editor_key: example_id
{
  "_snippets": {
    "example": {
      "snippet": "<<example [[param]]>>",
      "params": {
        "param": {
          "parser": "argument",
          "options": {
            "model": {
              "editor_key": "example_id"
            }
          }
        }
      }
    }
  }
}
Examples:

In this example, we have configured an argument parser to parse a single positional argument.

Markdown
Copied to clipboard
{{<figure image.png>}}
          └───────┘

In this example, we have configured an argument parser to parse a list of repeating arguments.

Markdown
Copied to clipboard
{{<images image1.png image2.png image3.png>}}
          └──────────────────────────────┘
Open in a new tab