mirror of
https://github.com/jimeh/dotify.git
synced 2026-02-19 10:06:39 +00:00
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:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user