Merge pull request #110 from opencultureconsulting/108-templating-export-shall-discard-trailing-newline-in-template-file

export template: remove trailing newline from input
This commit is contained in:
Felix Lohmeier 2023-10-26 01:27:22 +02:00 committed by GitHub
commit 6b3ce8f37d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 6 deletions

5
orcli
View File

@ -1777,10 +1777,13 @@ orcli_export_template_command() {
fi fi
fi fi
# read args[file] into variable to remove trailing newline
template=$(cat "${args[file]}")
# assemble specific post data # assemble specific post data
data+=("project=${projectid}") data+=("project=${projectid}")
data+=("format=template") data+=("format=template")
data+=("template@${args[file]}") data+=("template=${template}")
if [[ ${args[--prefix]} ]]; then if [[ ${args[--prefix]} ]]; then
data+=("prefix=${args[--prefix]}") data+=("prefix=${args[--prefix]}")
fi fi

View File

@ -29,10 +29,13 @@ else
fi fi
fi fi
# read args[file] into variable to remove trailing newline
template=$(cat "${args[file]}")
# assemble specific post data # assemble specific post data
data+=("project=${projectid}") data+=("project=${projectid}")
data+=("format=template") data+=("format=template")
data+=("template@${args[file]}") data+=("template=${template}")
if [[ ${args[--prefix]} ]]; then if [[ ${args[--prefix]} ]]; then
data+=("prefix=${args[--prefix]}") data+=("prefix=${args[--prefix]}")
fi fi

View File

@ -12,9 +12,7 @@ cp data/duplicates.csv "${tmpdir}/${t}.csv"
# assertion # assertion
cat << "DATA" > "${tmpdir}/${t}.assert" cat << "DATA" > "${tmpdir}/${t}.assert"
{ "events" : [{ "name" : "Ben Tyler", "purchase" : "Flashlight" } { "events" : [{ "name" : "Ben Tyler", "purchase" : "Flashlight" },{ "name" : "Ben Morisson", "purchase" : "Amplifier" }]}
,{ "name" : "Ben Morisson", "purchase" : "Amplifier" }
]}
DATA DATA
# action # action
@ -24,7 +22,7 @@ orcli export template "${t}" --output "${t}.output" \
<<< '{ "name" : {{jsonize(cells["name"].value)}}, "purchase" : {{jsonize(cells["purchase"].value)}} }' \ <<< '{ "name" : {{jsonize(cells["name"].value)}}, "purchase" : {{jsonize(cells["purchase"].value)}} }' \
--prefix '{ "events" : [' \ --prefix '{ "events" : [' \
--separator , \ --separator , \
--mode rows \ --mode records \
--suffix ]}$'\n' \ --suffix ]}$'\n' \
--facets '[ { "type": "text", "name": "foo", "columnName": "name", "mode": "regex", "caseSensitive": false, "query": "Ben" } ]' --facets '[ { "type": "text", "name": "foo", "columnName": "name", "mode": "regex", "caseSensitive": false, "query": "Ben" } ]'