Skip to content

Support default values for variables in request files #30

Description

@mantono

Support two types of default values in request files:

  • static {{FOO:bar}} - if no value is present for variable FOO use static value bar
  • dynamic {{FOO|bar}} - if no value is present for variable FOO invoke shell command bar which should provide a value instead

Static default value

For example

url: https://example.com
method: POST
headers:
  content-type: {{CONTENT_TYPE:application/json}}

So if a value is provided for CONTENT_TYPE it will always be used, regardless of where (i.e interactively, on the command line, through an environment or secret file) and only if no value is provided will we use the default value (application/json).

If a default value is provided and the --interactive flag is present, the user will NOT be asked to provide a value. Asking the user will only be done as a last resort.

Dynamic default value

For example

url: https://example.com
method: POST
headers:
  x-correlation-id: {{CORRELATION_ID|uuidgen}}

Similar to a static default value; if a value id provided somehow for CORRELATION_ID it will be used, but otherwise we will get a value by invoking the shell command uuidgen. So

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions