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
# read args[file] into variable to remove trailing newline
template=$(cat "${args[file]}")
# assemble specific post data
data+=("project=${projectid}")
data+=("format=template")
data+=("template@${args[file]}")
data+=("template=${template}")
if [[ ${args[--prefix]} ]]; then
data+=("prefix=${args[--prefix]}")
fi

View File

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

View File

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