mirror of
https://github.com/tests-always-included/mo.git
synced 2025-11-19 23:34:32 +01:00
Updates for how to source "mo" and then use it
When you source mo, it adds the "mo" function to the environment.
This commit is contained in:
@@ -4,8 +4,9 @@ cd "$(dirname "$0")" # Go to the script's directory
|
||||
|
||||
declare -A DATA
|
||||
DATA=([one]=111 [two]=222)
|
||||
. ../mo
|
||||
|
||||
cat <<EOF | . ../mo
|
||||
cat <<EOF | mo
|
||||
Accessing data directly:
|
||||
DATA: {{DATA}}
|
||||
One: {{DATA.one}}
|
||||
|
||||
@@ -11,7 +11,8 @@ export OPTIONS=(
|
||||
"Call a service representative at 1-800-000-0000 to discuss payment options"
|
||||
"Return the vehicle immediately and pay a fine of 1 million dollars"
|
||||
)
|
||||
sed '0,/^# END/ d' "$(basename "$0")" | . ../mo
|
||||
. ../mo
|
||||
sed '0,/^# END/ d' "$(basename "$0")" | mo
|
||||
exit
|
||||
|
||||
# END
|
||||
|
||||
@@ -28,8 +28,8 @@ declare -A resque hub rip
|
||||
resque=([name]=Resque [url]=http://example.com/resque)
|
||||
hub=([name]=Hub [url]=http://example.com/hub)
|
||||
rip=([name]=Rip [url]=http://example.com/rip)
|
||||
|
||||
cat <<EOF | . ../mo
|
||||
. ../mo
|
||||
cat <<EOF | mo
|
||||
{{#EVERY_REPO}}
|
||||
The repo is __REPO__
|
||||
Name: {{__REPO__.name}}
|
||||
|
||||
@@ -8,7 +8,8 @@ wrapper() { echo -n "*** $1 ***"; }
|
||||
export IP=127.0.0.1
|
||||
export ALLOWED_HOSTS=( 192.168.0.1 192.168.0.2 192.168.0.3 )
|
||||
|
||||
cat <<EOF | . mo
|
||||
. mo # Keep in mind this script is executing in the parent directory
|
||||
cat <<EOF | mo
|
||||
# {{#wrapper}}OH SO IMPORTANT{{/wrapper}}
|
||||
# This file automatically generated at {{date-string}}
|
||||
home_ip={{IP}}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#!/bin/bash
|
||||
cd "$(dirname "$0")" # Go to the script's directory
|
||||
export ARRAY=( one two "three three three" four five )
|
||||
cat << EOF | . ../mo
|
||||
. ../mo
|
||||
cat << EOF | mo
|
||||
Here are the items in the array:
|
||||
{{#ARRAY}}
|
||||
* {{.}}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# This example does not source `mo` and is intentionally restricted to
|
||||
# variables that are not arrays.
|
||||
cd "$(dirname "$0")" # Go to the script's directory
|
||||
export TEST="This is a test"
|
||||
echo "Your message: {{TEST}}" | ../mo
|
||||
|
||||
Reference in New Issue
Block a user