@Option(required = false, help = "the package in which to build this Interface", description = "source package", type = PromptType.JAVA_PACKAGE, name = "package") final String pckg,
@Option(required = false, help = "the interface definition: surround with quotes", description = "interface definition") final String... def)
throws FileNotFoundException
{
JavaSourceFacet java = project.getFacet(JavaSourceFacet.class);
JavaInterface jc = null;
if (def != null)
{
String classDef = Strings.join(Arrays.asList(def), " ");
jc = JavaParser.parse(JavaInterface.class, classDef);
}
else if (in != null)
{
jc = JavaParser.parse(JavaInterface.class, in);
}
else if (interfaceName != null)
{
jc = JavaParser.create(JavaInterface.class).setName(interfaceName);
}
else
{
throw new RuntimeException("arguments required");
}
if (pckg != null)
{
jc.setPackage(pckg);
}
if (!jc.hasSyntaxErrors())
{
java.saveJavaSource(jc);
}
else
{
writer.println(ShellColor.RED, "Syntax Errors:");
for (SyntaxError error : jc.getSyntaxErrors())
{
writer.println(error.toString());
}
writer.println();
if (prompt.promptBoolean(