Skip to content

Commit a4451b7

Browse files
committed
Merge pull request #85 from scijava/macro-options
Support implicit script parameters
2 parents 6cf115f + 75a244c commit a4451b7

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

src/main/java/org/scijava/module/DefaultModuleService.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -343,17 +343,23 @@ private void assignInputs(final Module module,
343343

344344
for (final String name : inputMap.keySet()) {
345345
final ModuleItem<?> input = module.getInfo().getInput(name);
346+
final Object value = inputMap.get(name);
347+
final Object converted;
346348
if (input == null) {
347-
log.error("No such input: " + name);
348-
continue;
349+
// inputs whose name starts with a dot are implicitly known by convention
350+
if (!name.startsWith(".")) {
351+
log.warn("Unmatched input: " + name);
352+
}
353+
converted = value;
349354
}
350-
final Object value = inputMap.get(name);
351-
final Class<?> type = input.getType();
352-
final Object converted = ConversionUtils.convert(value, type);
353-
if (value != null && converted == null) {
354-
log.error("For input " + name + ": incompatible object " +
355-
value.getClass().getName() + " for type " + type.getName());
356-
continue;
355+
else {
356+
final Class<?> type = input.getType();
357+
converted = ConversionUtils.convert(value, type);
358+
if (value != null && converted == null) {
359+
log.error("For input " + name + ": incompatible object " +
360+
value.getClass().getName() + " for type " + type.getName());
361+
continue;
362+
}
357363
}
358364
module.setInput(name, converted);
359365
module.setResolved(name, true);

src/main/java/org/scijava/module/ModuleInfo.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
* A ModuleInfo object encapsulates metadata about a particular {@link Module}
4141
* (but not a specific instance of it). In particular, it can report details on
4242
* the names and types of inputs and outputs.
43+
* <p>
44+
* A special class of implicit input parameters is available: when the
45+
* {@code name} starts with a dot (e.g. {@code .helloWorld}), no warning is
46+
* issued about an unmatched input.
47+
* </p>
4348
*
4449
* @author Aivar Grislis
4550
* @author Curtis Rueden

src/main/java/org/scijava/script/ScriptInfo.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@
5656

5757
/**
5858
* Metadata about a script.
59+
* <p>
60+
* This class is responsible for parsing the script for parameters. See
61+
* {@link #parseParameters()} for details.
62+
* </p>
5963
*
6064
* @author Curtis Rueden
6165
* @author Johannes Schindelin

0 commit comments

Comments
 (0)