Expand Dotfile syntax support to not require a <source> argument

Supported action syntax:

- `<action>: <source> -> <target>`
- `<action>: -> <target>`
- `<source> -> <target>`
- `-> <target>`
This commit is contained in:
2014-03-08 13:29:07 +00:00
parent 8fa09ea3c3
commit e0f0177301
3 changed files with 35 additions and 3 deletions

View File

@@ -20,12 +20,22 @@ compile-dotfile() {
output="${output}$(trim "${BASH_REMATCH[3]}") "
output="${output}$(trim "${BASH_REMATCH[4]}")\n"
# Parse "<action>: -> <target>" lines.
elif [[ "$line" =~ ^(\ +)?([a-zA-Z0-9_-]+):\ *-[\>]\ +(.+)$ ]]; then
output="${output}${BASH_REMATCH[1]}dotify-action ${BASH_REMATCH[2]} "
output="${output}$(trim "${BASH_REMATCH[3]}")\n"
# Parse "<source> -> <target>" lines.
elif [[ "$line" =~ ^(\ +)?(.+)\ -[\>]\ (.+)$ ]]; then
output="${output}${BASH_REMATCH[1]}dotify-action default "
output="${output}$(trim "${BASH_REMATCH[2]}") "
output="${output}$(trim "${BASH_REMATCH[3]}")\n"
# Parse "-> <target>" lines.
elif [[ "$line" =~ ^(\ +)?-[\>]\ (.+)$ ]]; then
output="${output}${BASH_REMATCH[1]}dotify-action default "
output="${output}$(trim "${BASH_REMATCH[2]}")\n"
# Append line without modifications.
else
output="${output}${line}\n"