@Test public void testParseInputs_dateTime_epochDate() { Map<String, Literal> inputs = parseInputs( ImmutableMap.of("datetime", createVar(SimpleType.DATETIME)), new String[] {"--datetime=1970-01-01"}); assertEquals( ImmutableMap.of("datetime", literalOf(Primitive.ofDatetime(Instant.EPOCH))), inputs); }
public Map<String, Literal> parseInputs( String synopsis, Map<String, Variable> variableMap, List<String> inputArgs) { CommandLine.Model.CommandSpec spec = CommandLine.Model.CommandSpec.create(); spec.usageMessage().customSynopsis(synopsis); variableMap.forEach((name, variable) -> spec.addOption(getOption(name, variable))); CommandLine.ParseResult result = new CommandLine(spec).parseArgs(inputArgs.toArray(new String[0])); return variableMap.entrySet().stream() .map( kv -> { String name = kv.getKey(); Literal defaultValue = getDefaultValueAsLiteral(name, kv.getValue()); return Maps.immutableEntry(name, result.matchedOptionValue(name, defaultValue)); }) .collect(toMap(Map.Entry::getKey, Map.Entry::getValue)); }
ExecuteLocalArgsParser { public Map<String, Literal> parseInputs( String synopsis, Map<String, Variable> variableMap, List<String> inputArgs) { CommandLine.Model.CommandSpec spec = CommandLine.Model.CommandSpec.create(); spec.usageMessage().customSynopsis(synopsis); variableMap.forEach((name, variable) -> spec.addOption(getOption(name, variable))); CommandLine.ParseResult result = new CommandLine(spec).parseArgs(inputArgs.toArray(new String[0])); return variableMap.entrySet().stream() .map( kv -> { String name = kv.getKey(); Literal defaultValue = getDefaultValueAsLiteral(name, kv.getValue()); return Maps.immutableEntry(name, result.matchedOptionValue(name, defaultValue)); }) .collect(toMap(Map.Entry::getKey, Map.Entry::getValue)); } }
ExecuteLocalArgsParser { public Map<String, Literal> parseInputs( String synopsis, Map<String, Variable> variableMap, List<String> inputArgs) { CommandLine.Model.CommandSpec spec = CommandLine.Model.CommandSpec.create(); spec.usageMessage().customSynopsis(synopsis); variableMap.forEach((name, variable) -> spec.addOption(getOption(name, variable))); CommandLine.ParseResult result = new CommandLine(spec).parseArgs(inputArgs.toArray(new String[0])); return variableMap.entrySet().stream() .map( kv -> { String name = kv.getKey(); Literal defaultValue = getDefaultValueAsLiteral(name, kv.getValue()); return Maps.immutableEntry(name, result.matchedOptionValue(name, defaultValue)); }) .collect(toMap(Map.Entry::getKey, Map.Entry::getValue)); }  }
ExecuteLocalArgsParser { public Map<String, Literal> parseInputs( String synopsis, Map<String, Variable> variableMap, List<String> inputArgs) { CommandLine.Model.CommandSpec spec = CommandLine.Model.CommandSpec.create(); spec.usageMessage().customSynopsis(synopsis); variableMap.forEach((name, variable) -> spec.addOption(getOption(name, variable))); CommandLine.ParseResult result = new CommandLine(spec).parseArgs(inputArgs.toArray(new String[0])); return variableMap.entrySet().stream() .map( kv -> { String name = kv.getKey(); Literal defaultValue = getDefaultValueAsLiteral(name, kv.getValue()); return Maps.immutableEntry(name, result.matchedOptionValue(name, defaultValue)); }) .collect(toMap(Map.Entry::getKey, Map.Entry::getValue)); }  Map<String, Literal> parseInputs(
      String synopsis, Map<String, Variable> variableMap, List<String> inputArgs); }
ExecuteLocalArgsParser { public Map<String, Literal> parseInputs( String synopsis, Map<String, Variable> variableMap, List<String> inputArgs) { CommandLine.Model.CommandSpec spec = CommandLine.Model.CommandSpec.create(); spec.usageMessage().customSynopsis(synopsis); variableMap.forEach((name, variable) -> spec.addOption(getOption(name, variable))); CommandLine.ParseResult result = new CommandLine(spec).parseArgs(inputArgs.toArray(new String[0])); return variableMap.entrySet().stream() .map( kv -> { String name = kv.getKey(); Literal defaultValue = getDefaultValueAsLiteral(name, kv.getValue()); return Maps.immutableEntry(name, result.matchedOptionValue(name, defaultValue)); }) .collect(toMap(Map.Entry::getKey, Map.Entry::getValue)); }  Map<String, Literal> parseInputs(
      String synopsis, Map<String, Variable> variableMap, List<String> inputArgs);  }