csv/tsv option columnNames and projectTags

This commit is contained in:
felixlohmeier 2023-01-09 10:38:53 +00:00
parent 27ee2ef650
commit 5cf03927b6
5 changed files with 617 additions and 196 deletions

720
orcli

File diff suppressed because it is too large Load Diff

View File

@ -73,6 +73,10 @@ commands:
- &blankCellsAsStrings
long: --blankCellsAsStrings
help: store blank cells as empty strings instead of nulls
- &columnNames
long: --columnNames
help: set column names (comma separated)
arg: columnNames
- &encoding_import
long: --encoding
help: set character encoding
@ -124,6 +128,10 @@ commands:
long: --projectName
arg: projectName
help: set a name for the OpenRefine project
- &projectTags
long: --projectTags
help: set project tags (comma separated)
arg: projectTags
- *quiet
examples:
- orcli import csv "file"
@ -142,9 +150,22 @@ commands:
args:
- *file
flags:
- *blankCellsAsStrings
- *columnNames
- *encoding_import
- *guessCellValueTypes
- *headerLines
- *ignoreLines
- *ignoreQuoteCharacter
- *includeFileSources
- *includeArchiveFileName
- *limit
- *quoteCharacter
- *skipBlankRows
- *skipDataLines
- *trimStrings
- *projectName
- *projectTags
- *quiet
examples:
- orcli import tsv "file"

View File

@ -23,6 +23,11 @@ if [[ ${args[--blankCellsAsStrings]} ]]; then
options+=', '
options+='"storeBlankCellsAsNulls": false'
fi
if [[ ${args[--columnNames]} ]]; then
IFS=',' read -ra columnNames <<< "${args[--columnNames]}"
options+=', '
options+="\"columnNames\": [ $(printf ',"'%s'"' "${columnNames[@]}" | cut -c2-) ]"
fi
if [[ ${args[--guessCellValueTypes]} ]]; then
options+=', '
options+='"guessCellValueTypes": true'
@ -71,6 +76,11 @@ if [[ ${args[--trimStrings]} ]]; then
options+=', '
options+='"trimStrings": true'
fi
if [[ ${args[--projectTags]} ]]; then
IFS=',' read -ra projectTags <<< "${args[--projectTags]}"
options+=', '
options+="\"projectTags\": [ $(printf ',"'%s'"' "${projectTags[@]}" | cut -c2-) ]"
fi
options+=' }'
data+=("options=${options}")

View File

@ -19,9 +19,65 @@ if [[ ${args[--encoding]} ]]; then
options+=', '
options+="\"encoding\": \"${args[--encoding]}\""
fi
if [[ ${args[--blankCellsAsStrings]} ]]; then
options+=', '
options+='"storeBlankCellsAsNulls": false'
fi
if [[ ${args[--columnNames]} ]]; then
options+=', '
options+="\"columnNames\": \"[${args[--columnNames]}\"]"
fi
if [[ ${args[--guessCellValueTypes]} ]]; then
options+=', '
options+='"guessCellValueTypes": true'
fi
if [[ ${args[--headerLines]} ]]; then
options+=', '
options+="\"headerLines\": ${args[--headerLines]}"
fi
if [[ ${args[--ignoreLines]} ]]; then
options+=', '
options+="\"ignoreLines\": ${args[--ignoreLines]}"
fi
if [[ ${args[--ignoreQuoteCharacter]} ]]; then
options+=', '
options+='"processQuotes": false'
fi
if [[ ${args[--includeFileSources]} ]]; then
options+=', '
options+='includeFileSources: true'
fi
if [[ ${args[--includeArchiveFileName]} ]]; then
options+=', '
options+='"includeArchiveFileName": true'
fi
if [[ ${args[--limit]} ]]; then
options+=', '
options+="\"limit\": ${args[--limit]}"
fi
if [[ ${args[--projectName]} ]]; then
options+=', '
options+="\"projectName\": \"${args[--projectName]}\""
fi
if [[ ${args[--quoteCharacter]} ]]; then
options+=', '
options+="\"quoteCharacter\": \"${args[--quoteCharacter]}\""
fi
if [[ ${args[--skipBlankRows]} ]]; then
options+=', '
options+='"storeBlankRows": false'
fi
if [[ ${args[--skipDataLines]} ]]; then
options+=', '
options+="\"skipDataLines\": ${args[--skipDataLines]}"
fi
if [[ ${args[--trimStrings]} ]]; then
options+=', '
options+="\"trimStrings\": true"
options+='"trimStrings": true'
fi
if [[ ${args[--projectTags]} ]]; then
options+=', '
options+="\"projectTags\": \"[${args[--projectTags]}\"]"
fi
options+=' }'
data+=("options=${options}")

View File

@ -35,11 +35,11 @@ send_completions() {
echo $' ;;'
echo $''
echo $' \'import csv\'*)'
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_orcli_completions_filter "--blankCellsAsStrings --encoding --guessCellValueTypes --headerLines --help --ignoreLines --ignoreQuoteCharacter --includeArchiveFileName --includeFileSources --limit --projectName --quiet --quoteCharacter --separator --skipBlankRows --skipDataLines --trimStrings -h -q")" -- "$cur" )'
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_orcli_completions_filter "--blankCellsAsStrings --columnNames --encoding --guessCellValueTypes --headerLines --help --ignoreLines --ignoreQuoteCharacter --includeArchiveFileName --includeFileSources --limit --projectName --projectTags --quiet --quoteCharacter --separator --skipBlankRows --skipDataLines --trimStrings -h -q")" -- "$cur" )'
echo $' ;;'
echo $''
echo $' \'import tsv\'*)'
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_orcli_completions_filter "--encoding --help --projectName --quiet --trimStrings -h -q")" -- "$cur" )'
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_orcli_completions_filter "--blankCellsAsStrings --columnNames --encoding --guessCellValueTypes --headerLines --help --ignoreLines --ignoreQuoteCharacter --includeArchiveFileName --includeFileSources --limit --projectName --projectTags --quiet --quoteCharacter --skipBlankRows --skipDataLines --trimStrings -h -q")" -- "$cur" )'
echo $' ;;'
echo $''
echo $' \'export tsv\'*)'