-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use GETOPT for the command line scripts #326
- Loading branch information
Showing
11 changed files
with
536 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,113 @@ | ||
# Calling Validator | ||
# Calling completeness | ||
. ./common-variables | ||
ME=$(basename $0) | ||
|
||
/usr/bin/java -Xmx2g -cp $JAR de.gwdg.metadataqa.marc.cli.Completeness "$@" | ||
show_usage() { # display help message | ||
cat <<EOF | ||
QA catalogue completeness analysis | ||
|
||
usage: | ||
${ME} [options] <files> | ||
|
||
options: | ||
-m, --marcVersion <arg> MARC version ('OCLC' or 'DNB') | ||
-h, --help display help | ||
-n, --nolog do not display log messages | ||
-l, --limit <arg> limit the number of records to process | ||
-o, --offset <arg> the first record to process | ||
-i, --id <arg> the MARC identifier (content of 001) | ||
-d, --defaultRecordType <arg> the default record type if the record's type is undetectable | ||
-q, --fixAlephseq fix the known issues of Alephseq format | ||
-a, --fixAlma fix the known issues of Alma format | ||
-b, --fixKbr fix the known issues of Alma format | ||
-p, --alephseq the source is in Alephseq format | ||
-x, --marcxml the source is in MARCXML format | ||
-y, --lineSeparated the source is in line separated MARC format | ||
-t, --outputDir <arg> output directory | ||
-r, --trimId remove spaces from the end of record IDs | ||
-z, --ignorableFields <arg> ignore fields from the analysis | ||
-v, --ignorableRecords <arg> ignore records from the analysis | ||
-f, --marcFormat <arg> MARC format (like 'ISO' or 'MARCXML') | ||
-s, --dataSource <arg> data source (file of stream) | ||
-g, --defaultEncoding <arg> default character encoding | ||
-1, --alephseqLineType <arg> Alephseq line type | ||
-2, --picaIdField <arg> PICA id field | ||
-u, --picaSubfieldSeparator <arg> PICA subfield separator | ||
-j, --picaSchemaFile <arg> Avram PICA schema file | ||
-w, --schemaType <arg> metadata schema type ('MARC21', 'UNIMARC', or 'PICA') | ||
-k, --picaRecordType <arg> picaRecordType | ||
-c, --allowableRecords <arg> allow records for the analysis | ||
-e, --groupBy <arg> group the results by the value of this data element (e.g. the ILN of library) | ||
-3, --groupListFile <arg> the file which contains a list of ILN codes | ||
-R, --format <arg> specify a format | ||
-V, --advanced advanced mode (not yet implemented) | ||
-P, --onlyPackages only packages (not yet implemented) | ||
|
||
more info: https://github.com/pkiraly/qa-catalogue#calculating-data-element-completeness | ||
|
||
EOF | ||
exit 1 | ||
} | ||
|
||
if [ $# -eq 0 ]; then | ||
show_usage | ||
fi | ||
|
||
SHORT_OPTIONS="m:hnl:o:i:d:qabpxyt:rz:v:f:s:g:1:2:u:j:w:k:c:e:3:R:VP" | ||
LONG_OPTIONS="marcVersion:,help,nolog,limit:,offset:,id:,defaultRecordType:,fixAlephseq,fixAlma,fixKbr,alephseq,marcxml,lineSeparated,outputDir:,trimId,ignorableFields:,ignorableRecords:,marcFormat:,dataSource:,defaultEncoding:,alephseqLineType:,picaIdField:,picaSubfieldSeparator:,picaSchemaFile:,schemaType:,picaRecordType:,allowableRecords:,groupBy:,groupListFile:,format:,advanced,onlyPackages" | ||
|
||
GETOPT=$(getopt \ | ||
-o ${SHORT_OPTIONS} \ | ||
--long ${LONG_OPTIONS} \ | ||
-n ${ME} -- "$@") | ||
eval set -- "${GETOPT}" | ||
|
||
PARAMS="" | ||
HELP=0 | ||
while true ; do | ||
case "$1" in | ||
-m|--marcVersion) PARAMS="$PARAMS --marcVersion $2" ; shift 2 ;; | ||
-h|--help) PARAMS="$PARAMS --help" ; HELP=1; shift ;; | ||
-n|--nolog) PARAMS="$PARAMS --nolog" ; shift ;; | ||
-l|--limit) PARAMS="$PARAMS --limit $2" ; shift 2 ;; | ||
-o|--offset) PARAMS="$PARAMS --offset $2" ; shift 2 ;; | ||
-i|--id) PARAMS="$PARAMS --id $2" ; shift 2 ;; | ||
-d|--defaultRecordType) PARAMS="$PARAMS --defaultRecordType $2" ; shift 2 ;; | ||
-q|--fixAlephseq) PARAMS="$PARAMS --fixAlephseq" ; shift ;; | ||
-a|--fixAlma) PARAMS="$PARAMS --fixAlma" ; shift ;; | ||
-b|--fixKbr) PARAMS="$PARAMS --fixKbr" ; shift ;; | ||
-p|--alephseq) PARAMS="$PARAMS --alephseq" ; shift ;; | ||
-x|--marcxml) PARAMS="$PARAMS --marcxml" ; shift ;; | ||
-y|--lineSeparated) PARAMS="$PARAMS --lineSeparated" ; shift ;; | ||
-t|--outputDir) PARAMS="$PARAMS --outputDir $2" ; shift 2 ;; | ||
-r|--trimId) PARAMS="$PARAMS --trimId" ; shift ;; | ||
-z|--ignorableFields) PARAMS="$PARAMS --ignorableFields $2" ; shift 2 ;; | ||
-v|--ignorableRecords) PARAMS="$PARAMS --ignorableRecords $2" ; shift 2 ;; | ||
-f|--marcFormat) PARAMS="$PARAMS --marcFormat $2" ; shift 2 ;; | ||
-s|--dataSource) PARAMS="$PARAMS --dataSource $2" ; shift 2 ;; | ||
-g|--defaultEncoding) PARAMS="$PARAMS --defaultEncoding $2" ; shift 2 ;; | ||
-1|--alephseqLineType) PARAMS="$PARAMS --alephseqLineType $2" ; shift 2 ;; | ||
-2|--picaIdField) PARAMS="$PARAMS --picaIdField $2" ; shift 2 ;; | ||
-u|--picaSubfieldSeparator) PARAMS="$PARAMS --picaSubfieldSeparator $2" ; shift 2 ;; | ||
-j|--picaSchemaFile) PARAMS="$PARAMS --picaSchemaFile $2" ; shift 2 ;; | ||
-w|--schemaType) PARAMS="$PARAMS --schemaType $2" ; shift 2 ;; | ||
-k|--picaRecordType) PARAMS="$PARAMS --picaRecordType $2" ; shift 2 ;; | ||
-c|--allowableRecords) PARAMS="$PARAMS --allowableRecords $2" ; shift 2 ;; | ||
-e|--groupBy) PARAMS="$PARAMS --groupBy $2" ; shift 2 ;; | ||
-3|--groupListFile) PARAMS="$PARAMS --groupListFile $2" ; shift 2 ;; | ||
-R|--format) PARAMS="$PARAMS --format $2" ; shift 2 ;; | ||
-V|--advanced) PARAMS="$PARAMS --advanced" ; shift ;; | ||
-P|--onlyPackages) PARAMS="$PARAMS --onlyPackages" ; shift ;; | ||
--) shift ; break ;; | ||
*) echo "Internal error!: $1" ; exit 1 ;; | ||
esac | ||
done | ||
|
||
if [[ $HELP -eq 1 ]]; then | ||
show_usage | ||
fi | ||
|
||
CMD="/usr/bin/java -Xmx2g -cp $JAR de.gwdg.metadataqa.marc.cli.Completeness" | ||
|
||
echo $CMD $PARAMS "$@" | ||
$CMD $PARAMS "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
This directory helps to generate the CLI scripts' help and getopt parts | ||
|
||
Usage: | ||
```bash | ||
php generate <file> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
options.addOption("m", "marcVersion", true, "MARC version ('OCLC' or 'DNB')"); | ||
options.addOption("h", "help", false, "display help"); | ||
options.addOption("n", "nolog", false, "do not display log messages"); | ||
options.addOption("l", "limit", true, "limit the number of records to process"); | ||
options.addOption("o", "offset", true, "the first record to process"); | ||
options.addOption("i", "id", true, "the MARC identifier (content of 001)"); | ||
options.addOption("d", "defaultRecordType", true, "the default record type if the record's type is undetectable"); | ||
options.addOption("q", "fixAlephseq", false, "fix the known issues of Alephseq format"); | ||
options.addOption("a", "fixAlma", false, "fix the known issues of Alma format"); | ||
options.addOption("b", "fixKbr", false, "fix the known issues of Alma format"); | ||
options.addOption("p", "alephseq", false, "the source is in Alephseq format"); | ||
options.addOption("x", "marcxml", false, "the source is in MARCXML format"); | ||
options.addOption("y", "lineSeparated", false, "the source is in line separated MARC format"); | ||
options.addOption("t", "outputDir", true, "output directory"); | ||
options.addOption("r", "trimId", false, "remove spaces from the end of record IDs"); | ||
options.addOption("z", "ignorableFields", true, "ignore fields from the analysis"); | ||
options.addOption("v", "ignorableRecords", true, "ignore records from the analysis"); | ||
options.addOption("f", "marcFormat", true, "MARC format (like 'ISO' or 'MARCXML')"); | ||
options.addOption("s", "dataSource", true, "data source (file of stream)"); | ||
options.addOption("g", "defaultEncoding", true, "default character encoding"); | ||
options.addOption("1", "alephseqLineType", true, "Alephseq line type"); | ||
options.addOption("2", "picaIdField", true, "PICA id field"); | ||
options.addOption("u", "picaSubfieldSeparator", true, "PICA subfield separator"); | ||
options.addOption("j", "picaSchemaFile", true, "Avram PICA schema file"); | ||
options.addOption("w", "schemaType", true, "metadata schema type ('MARC21', 'UNIMARC', or 'PICA')"); | ||
options.addOption("k", "picaRecordType", true, "picaRecordType"); | ||
options.addOption("c", "allowableRecords", true, "allow records for the analysis"); | ||
options.addOption("e", "groupBy", true, "group the results by the value of this data element (e.g. the ILN of library)"); | ||
options.addOption("3", "groupListFile", true, "the file which contains a list of ILN codes"); | ||
options.addOption("R", "format", true, "specify a format"); | ||
options.addOption("V", "advanced", false, "advanced mode (not yet implemented)"); | ||
options.addOption("P", "onlyPackages", false, "only packages (not yet implemented)"); |
Oops, something went wrong.