Skip to content
This repository was archived by the owner on Oct 11, 2023. It is now read-only.
This repository was archived by the owner on Oct 11, 2023. It is now read-only.

Document use of Validation section #100

@SorraTheOrc

Description

@SorraTheOrc

Validation sections are both a normal part of a document and a way to test if a prerequisite is run. This issue is about their use as a normal part of a document. In this mode the validation section should be run. Consider the example below which should output and/or test the value of UNIQUE_FILENAME when run in any mode.

ASIDE: I've written this example as both documentation and test script... where should it live?

How to use Environment Variables to Configure SimDem Scripts

It can be convenient to have a SimDem script that creates a number of environment variables for use in other scripts. This script can then be used as a prerequisite to ensure that you have a consistent environment on each execution. To set an environment variable use a command like the following:

MY_VARIABLE="My value"

You can use bash commands to create unique strings too:

UNIQUE_FILENAME=my_filename_$(date +%Y-%m-%d-%H)

If you want to avoid overwriting values provided by the SimDem user, you can easily do so with a value check:

if [ -z "$ANOTHER_UNIQUE_FILENAME" ]; then $ANOTHER_UNIQUE_FILENAME = my_filename_$(date +%Y-%m-%d-%H); fi

Validation

A validation section is useful in two ways. It can be used to ensure we output the final results when executing in a tutorial/demo environment and it can be used to test whether a prerequisite file needs to be run. For example:

if [ -z "$UNIQUE_FILENAME" ]; echo "We need to provide or generate a unique filename"; else "UNIQUE_FILENAME=$UNIQUE_FILENAME"; fi

Results:

UNIQUE_FILENAME=my_filename_yyyy-mm-dd-hh

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions