diff --git a/CHANGELOG.md b/CHANGELOG.md
index 82073b1d1..40198a9ed 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
--- Added option to input template strings from external file [#1152]
+- Added option to input template strings from external file [#1152]
### Fixed
- '--annotate-with-source true' does not work with extract --method subset [#1160]
@@ -391,6 +391,7 @@ First official release of ROBOT!
[#1171]: https://github.com/ontodev/robot/pull/1171
[#1168]: https://github.com/ontodev/robot/pull/1168
[#1160]: https://github.com/ontodev/robot/pull/1160
+[#1152]: https://github.com/ontodev/robot/issues/1152
[#1148]: https://github.com/ontodev/robot/pull/1148
[#1135]: https://github.com/ontodev/robot/pull/1135
[#1119]: https://github.com/ontodev/robot/pull/1119
@@ -535,4 +536,3 @@ First official release of ROBOT!
[#246]: https://github.com/ontodev/robot/issues/246
[#174]: https://github.com/ontodev/robot/issues/174
[#158]: https://github.com/ontodev/robot/issues/158
-[#1152]: https://github.com/ontodev/robot/issues/1152
\ No newline at end of file
diff --git a/docs/examples/animals_ext_template_error.tsv b/docs/examples/animals_ext_template_error.tsv
deleted file mode 100644
index 4e78657d6..000000000
--- a/docs/examples/animals_ext_template_error.tsv
+++ /dev/null
@@ -1,4 +0,0 @@
-CURIE Label Parent Comment
-obo:0000001 animal Any animal in the world.
-0000002 canine animal A member of the genus Canis.
-obo:0000003 feline animal A member of the genus Felis.
diff --git a/docs/template.md b/docs/template.md
index cacd47145..30e72cf8d 100644
--- a/docs/template.md
+++ b/docs/template.md
@@ -232,7 +232,7 @@ ROBOT template data read from separate external file
Adjusted line numbers for error reporting for template data read from separate external file
```
-robot template --template animals_ext_template_error.tsv \
+robot template --template animals_template_error.tsv \
--ext-template animals_ext_template.tsv \
--output results/animals_ext_template.owl
```
diff --git a/results/animals_ext_template.owl b/results/animals_ext_template.owl
deleted file mode 100644
index d37e98c42..000000000
--- a/results/animals_ext_template.owl
+++ /dev/null
@@ -1,55 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Any animal in the world.
- animal
-
-
-
-
-
-
-
-
- A member of the genus Canis.
- canine
-
-
-
-
-
-
-
-
- A member of the genus Felis.
- feline
-
-
-
-
-
-
-
diff --git a/robot-command/src/main/java/org/obolibrary/robot/TemplateCommand.java b/robot-command/src/main/java/org/obolibrary/robot/TemplateCommand.java
index 220d7ac38..637ef106a 100644
--- a/robot-command/src/main/java/org/obolibrary/robot/TemplateCommand.java
+++ b/robot-command/src/main/java/org/obolibrary/robot/TemplateCommand.java
@@ -155,21 +155,22 @@ public CommandState execute(CommandState state, String[] args) throws Exception
for (String templatePath : templatePaths) {
tables.put(templatePath, TemplateHelper.readTable(templatePath));
}
- // Read the robot header line in
- List robotHeaderPath = CommandLineHelper.getOptionValues(line, "external-template");
- if (robotHeaderPath.size() > 0) {
- // For now only a single header line file is considered
- List> headerLine = new ArrayList<>();
- headerLine = TemplateHelper.readTable(robotHeaderPath.get(0));
- if (headerLine.size() == 0) {
+
+ // Handle external template files.
+ List externalTemplatePath =
+ CommandLineHelper.getOptionValues(line, "external-template");
+ if (externalTemplatePath.size() > 0) {
+ List> externalTemplate = new ArrayList<>();
+ externalTemplate = TemplateHelper.readTable(externalTemplatePath.get(0));
+ if (externalTemplate.size() == 0) {
throw new IllegalArgumentException(missingRobotHeaderError);
}
- // Insert headerLine into all the template file data appropriately
+ // Insert externalTemplate into all the template file data appropriately
for (String templatePath : templatePaths) {
List> template = tables.get(templatePath);
- // check that header lines match
- if (checkHeaders(template.get(0), headerLine.get(0))) {
- template.add(1, headerLine.get(1));
+ // check that the first lines (headers) are the same
+ if (compareHeaders(template.get(0), externalTemplate.get(0))) {
+ template.add(1, externalTemplate.get(1));
} else {
throw new IllegalArgumentException(mismatchedRobotHeaderError);
}
@@ -229,14 +230,14 @@ public CommandState execute(CommandState state, String[] args) throws Exception
}
/**
- * Compare the headers for the template file and the external template file Return true or false
- * for match and mismatch situations respectively
+ * Compare the headers for the template file and the external template file. Return true if they
+ * match, false otherwise.
*
* @param templateHeader header from template file
* @param externalTemplateHeader header from external template file
* @return true for match, false for mismatch
*/
- private boolean checkHeaders(List templateHeader, List externalTemplateHeader) {
+ private boolean compareHeaders(List templateHeader, List externalTemplateHeader) {
if (templateHeader.size() == externalTemplateHeader.size()) {
int numElements = templateHeader.size();
for (int index = 0; index < numElements; index++) {