mirror of
https://github.com/tests-always-included/mo.git
synced 2026-04-08 08:50:38 +02:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dbefade193 | ||
|
|
57a8d41394 | ||
|
|
5739ccd705 | ||
|
|
f889c37316 | ||
|
|
4f615a0faf | ||
|
|
1e91e414cc | ||
|
|
ad98577c42 |
@@ -41,7 +41,7 @@ There are a few ways you can install this tool. How you install it depends on h
|
|||||||
You can install this file in `/usr/local/bin/` or `/usr/bin/` by simply downloading it, changing the permissions, then moving it to the right location. Double check that your system's PATH includes the destination folder, otherwise users may have a hard time starting the command.
|
You can install this file in `/usr/local/bin/` or `/usr/bin/` by simply downloading it, changing the permissions, then moving it to the right location. Double check that your system's PATH includes the destination folder, otherwise users may have a hard time starting the command.
|
||||||
|
|
||||||
# Download
|
# Download
|
||||||
curl -sS https://git.io/get-mo -o mo
|
curl -sSL https://git.io/get-mo -o mo
|
||||||
|
|
||||||
# Make executable
|
# Make executable
|
||||||
chmod +x mo
|
chmod +x mo
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
cd "$(dirname "$0")" # Go to the script's directory
|
cd "$(dirname "$0")" # Go to the script's directory
|
||||||
|
|
||||||
EVERY_REPO() {
|
EVERY_REPO() {
|
||||||
|
# The block contents come in through standard input. Capture it here.
|
||||||
|
content=$(cat)
|
||||||
|
|
||||||
echo "# Starting EVERY_REPO"
|
echo "# Starting EVERY_REPO"
|
||||||
|
|
||||||
# Get list of repos
|
# Get list of repos
|
||||||
@@ -14,7 +17,7 @@ EVERY_REPO() {
|
|||||||
# It rewrites {{__REPO__.name}} into {{resque.name}}, for instance.
|
# It rewrites {{__REPO__.name}} into {{resque.name}}, for instance.
|
||||||
# You can prefix your environment variables and do other things as well.
|
# You can prefix your environment variables and do other things as well.
|
||||||
|
|
||||||
echo -n "$1" | sed "s/__REPO__/${REPO}/"
|
echo "$content" | sed "s/__REPO__/${REPO}/"
|
||||||
|
|
||||||
echo "## Looped one time for repo: $REPO"
|
echo "## Looped one time for repo: $REPO"
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -2,13 +2,17 @@
|
|||||||
|
|
||||||
cd "$(dirname "$0")"/..
|
cd "$(dirname "$0")"/..
|
||||||
|
|
||||||
date-string() { date; }
|
date-string() {
|
||||||
wrapper() { echo -n "*** $1 ***"; }
|
date
|
||||||
|
}
|
||||||
|
wrapper() {
|
||||||
|
echo -n "*** $(cat) ***"
|
||||||
|
}
|
||||||
|
|
||||||
export IP=127.0.0.1
|
export IP=127.0.0.1
|
||||||
export ALLOWED_HOSTS=( 192.168.0.1 192.168.0.2 192.168.0.3 )
|
export ALLOWED_HOSTS=( 192.168.0.1 192.168.0.2 192.168.0.3 )
|
||||||
|
|
||||||
. mo # Keep in mind this script is executing in the parent directory
|
. ./mo # Keep in mind this script is executing in the parent directory
|
||||||
cat <<EOF | mo
|
cat <<EOF | mo
|
||||||
# {{#wrapper}}OH SO IMPORTANT{{/wrapper}}
|
# {{#wrapper}}OH SO IMPORTANT{{/wrapper}}
|
||||||
# This file automatically generated at {{date-string}}
|
# This file automatically generated at {{date-string}}
|
||||||
|
|||||||
22
mo
22
mo
@@ -141,15 +141,16 @@ mo() (
|
|||||||
#
|
#
|
||||||
# Returns nothing.
|
# Returns nothing.
|
||||||
moCallFunction() {
|
moCallFunction() {
|
||||||
local moCommand
|
local moArgs
|
||||||
|
|
||||||
|
moArgs=()
|
||||||
|
|
||||||
# shellcheck disable=SC2031
|
# shellcheck disable=SC2031
|
||||||
if [[ -n "$MO_ALLOW_FUNCTION_ARGUMENTS" ]]; then
|
if [[ -n "${MO_ALLOW_FUNCTION_ARGUMENTS-}" ]]; then
|
||||||
printf -v moCommand "%q %q %s" "$1" "$2" "$3"
|
moArgs=$3
|
||||||
eval "$moCommand"
|
|
||||||
else
|
|
||||||
"$1" "$2"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo -n "$2" | eval "$1" "$moArgs"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -834,15 +835,15 @@ moShow() {
|
|||||||
|
|
||||||
moSplit moNameParts "$1" "."
|
moSplit moNameParts "$1" "."
|
||||||
|
|
||||||
if [[ -z "${moNameParts[1]}" ]]; then
|
if [[ -z "${moNameParts[1]-}" ]]; then
|
||||||
if moIsArray "$1"; then
|
if moIsArray "$1"; then
|
||||||
eval moJoin moJoined "," "\${$1[@]}"
|
eval moJoin moJoined "," "\${$1[@]}"
|
||||||
echo -n "$moJoined"
|
echo -n "$moJoined"
|
||||||
else
|
else
|
||||||
# shellcheck disable=SC2031
|
# shellcheck disable=SC2031
|
||||||
if [[ -z "$MO_FAIL_ON_UNSET" ]] || moTestVarSet "$1"; then
|
if moTestVarSet "$1"; then
|
||||||
echo -n "${!1}"
|
echo -n "${!1}"
|
||||||
else
|
elif [[ -n "${MO_FAIL_ON_UNSET-}" ]]; then
|
||||||
echo "Env variable not set: $1" >&2
|
echo "Env variable not set: $1" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -1029,11 +1030,14 @@ moTrimWhitespace() {
|
|||||||
# Returns nothing.
|
# Returns nothing.
|
||||||
moUsage() {
|
moUsage() {
|
||||||
grep '^#/' "${MO_ORIGINAL_COMMAND}" | cut -c 4-
|
grep '^#/' "${MO_ORIGINAL_COMMAND}" | cut -c 4-
|
||||||
|
echo ""
|
||||||
|
set | grep ^MO_VERSION=
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Save the original command's path for usage later
|
# Save the original command's path for usage later
|
||||||
MO_ORIGINAL_COMMAND="$(cd "${BASH_SOURCE[0]%/*}" || exit 1; pwd)/${BASH_SOURCE[0]##*/}"
|
MO_ORIGINAL_COMMAND="$(cd "${BASH_SOURCE[0]%/*}" || exit 1; pwd)/${BASH_SOURCE[0]##*/}"
|
||||||
|
MO_VERSION="2.0.4"
|
||||||
|
|
||||||
# If sourced, load all functions.
|
# If sourced, load all functions.
|
||||||
# If executed, perform the actions as expected.
|
# If executed, perform the actions as expected.
|
||||||
|
|||||||
@@ -2,16 +2,12 @@ name=Willy
|
|||||||
MO_ALLOW_FUNCTION_ARGUMENTS=true
|
MO_ALLOW_FUNCTION_ARGUMENTS=true
|
||||||
|
|
||||||
pipeTo() {
|
pipeTo() {
|
||||||
echo -n "$1" | "$2"
|
cat | "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
testArgs() {
|
testArgs() {
|
||||||
printf "%d" "$#"
|
printf "%d" "$#"
|
||||||
|
|
||||||
# Remove content. Note that when zero arguments are passed, this
|
|
||||||
# line does nothing and $1 will still be the content.
|
|
||||||
shift
|
|
||||||
|
|
||||||
# Display all arguments
|
# Display all arguments
|
||||||
printf " %q" "$@"
|
printf " %q" ${@+"$@"}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
No args: 1 '' - done
|
No args: 0 '' - done
|
||||||
One arg: 2 one - done
|
One arg: 1 one - done
|
||||||
Getting name in a string: 2 The\ name\ is\ Willy - done
|
Getting name in a string: 1 The\ name\ is\ Willy - done
|
||||||
Reverse this: edcba
|
Reverse this: edcba
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
name=Willy
|
name=Willy
|
||||||
wrapped() {
|
wrapped() {
|
||||||
# The final newline is eaten by mo
|
# This eats the newline in the content
|
||||||
echo "<b>$1</b>"
|
echo "<b>$(cat)</b>"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
<b> Willy is awesome.
|
<b> Willy is awesome.</b>... this is the last line.
|
||||||
</b>... this is the last line.
|
|
||||||
|
|||||||
Reference in New Issue
Block a user