@DefaultCommand public void rm( @Option(name = "recursive", shortName = "r", help = "recursively delete resources", flagOnly = true) final boolean recursive, @Option(name = "force", shortName = "f", help = "do not prompt to confirm operations", flagOnly = true) final boolean force, @Option(description = "path", required = true) final Resource<?>[] paths) { for (Resource<?> resource : paths) { deleteResource(recursive, force, resource); } }
optionMeta.setName(option.name()); optionMeta.setShortName(option.shortName()); optionMeta.setFlagOnly(option.flagOnly()); optionMeta.setDescription(option.description()); optionMeta.setDefaultValue(option.defaultValue()); optionMeta.setHelp(option.help()); optionMeta.setRequired(option.required()); optionMeta.setPromptType(option.type()); optionMeta.setCompleterType(option.completer());
@DefaultCommand public void rename( @Option(description = "source", required = true) final Resource<?> source, @Option(description = "target", required = true) final String target, @Option(name = "force", shortName = "f", description = "force operation", flagOnly = true) final boolean force, final PipeOut out) { Resource<?> directory = this.directory; rename(source, directory, target, force, out); }
@DefaultCommand(help = "Add many custom field to an existing @Entity class") public void newExpressionField( @Option(required = true, description = "The field descriptor") final String... fields) { System.out.println(Arrays.asList(fields)); }
@Command(value = "NotNull", help = "Adds @NotNull constraint on the specified property") public void addNotNullConstraint( @Option(name = "onProperty", completer = PropertyCompleter.class, required = true) String property, @Option(name = "onAccessor", flagOnly = true) boolean onAccessor, @Option(name = "message") String message, @Option(name = "groups", type = JAVA_CLASS) String[] groups) throws FileNotFoundException { final Annotation<JavaClass> constraintAnnotation = addConstraintOnProperty(property, onAccessor, NotNull.class); setConstraintMessage(constraintAnnotation, message); javaSourceFacet.saveJavaSource(constraintAnnotation.getOrigin()); outputConstraintAdded(property, NotNull.class); }
@Command(value = "AssertTrue", help = "Adds @AssertTrue constraint on the specified property") public void addAssertTrueConstraint( @Option(name = "onProperty", completer = PropertyCompleter.class, required = true) String property, @Option(name = "onAccessor", flagOnly = true) boolean onAccessor, @Option(name = "message") String message, @Option(name = "groups", type = JAVA_CLASS) String[] groups) throws FileNotFoundException { final Annotation<JavaClass> constraintAnnotation = addConstraintOnProperty(property, onAccessor, AssertTrue.class); setConstraintMessage(constraintAnnotation, message); javaSourceFacet.saveJavaSource(constraintAnnotation.getOrigin()); outputConstraintAdded(property, AssertTrue.class); }
@Command(value = "Past", help = "Adds @Past constraint on the specified property") public void addPastConstraint( @Option(name = "onProperty", completer = PropertyCompleter.class, required = true) String property, @Option(name = "onAccessor", flagOnly = true) boolean onAccessor, @Option(name = "message") String message, @Option(name = "groups", type = JAVA_CLASS) String[] groups) throws FileNotFoundException { final Annotation<JavaClass> constraintAnnotation = addConstraintOnProperty(property, onAccessor, Past.class); setConstraintMessage(constraintAnnotation, message); javaSourceFacet.saveJavaSource(constraintAnnotation.getOrigin()); outputConstraintAdded(property, Past.class); }
@Command(value = "Future", help = "Adds @Future constraint on the specified property") public void addFutureConstraint( @Option(name = "onProperty", completer = PropertyCompleter.class, required = true) String property, @Option(name = "onAccessor", flagOnly = true) boolean onAccessor, @Option(name = "message") String message, @Option(name = "groups", type = JAVA_CLASS) String[] groups) throws FileNotFoundException { final Annotation<JavaClass> constraintAnnotation = addConstraintOnProperty(property, onAccessor, Future.class); setConstraintMessage(constraintAnnotation, message); javaSourceFacet.saveJavaSource(constraintAnnotation.getOrigin()); outputConstraintAdded(property, Future.class); }
@Command(value = "Null", help = "Adds @Null constraint on the specified property") public void addNullConstraint( @Option(name = "onProperty", completer = PropertyCompleter.class, required = true) String property, @Option(name = "onAccessor", flagOnly = true) boolean onAccessor, @Option(name = "message") String message, @Option(name = "groups", type = JAVA_CLASS) String[] groups) throws FileNotFoundException { final Annotation<JavaClass> constraint = addConstraintOnProperty(property, onAccessor, Null.class); setConstraintMessage(constraint, message); javaSourceFacet.saveJavaSource(constraint.getOrigin()); outputConstraintAdded(property, Null.class); }
@DefaultCommand public void build(final PipeOut out, @Option(name = "profile", completer = ProfileCompleter.class) String profile, @Option(description = "test arguments") String... args) { PackagingFacet packaging = project.getFacet(PackagingFacet.class); List<String> arguments = new ArrayList<String>(); arguments.add("test"); if (args != null) arguments.addAll(Arrays.asList(args)); if (profile != null) { arguments.add("-P" + profile); } packaging.executeBuild(arguments.toArray(new String[] {})); }
@Command(value = "Min", help = "Adds @Min constraint on the specified property") public void addMinConstraint( @Option(name = "onProperty", completer = PropertyCompleter.class, required = true) String property, @Option(name = "onAccessor", flagOnly = true) boolean onAccessor, @Option(name = "min", required = true) long min, @Option(name = "message") String message, @Option(name = "groups", type = JAVA_CLASS) String[] groups) throws FileNotFoundException { final Annotation<JavaClass> constraintAnnotation = addConstraintOnProperty(property, onAccessor, Min.class); setConstraintMessage(constraintAnnotation, message); constraintAnnotation.setLiteralValue(String.valueOf(min)); javaSourceFacet.saveJavaSource(constraintAnnotation.getOrigin()); outputConstraintAdded(property, Min.class); }
@Command(value = "Max", help = "Adds @Max constraint on the specified property") public void addMaxConstraint( @Option(name = "onProperty", completer = PropertyCompleter.class, required = true) String property, @Option(name = "onAccessor", flagOnly = true) boolean onAccessor, @Option(name = "max", required = true) long max, @Option(name = "message") String message, @Option(name = "groups", type = JAVA_CLASS) String[] groups) throws FileNotFoundException { final Annotation<JavaClass> constraintAnnotation = addConstraintOnProperty(property, onAccessor, Max.class); setConstraintMessage(constraintAnnotation, message); constraintAnnotation.setLiteralValue(String.valueOf(max)); javaSourceFacet.saveJavaSource(constraintAnnotation.getOrigin()); outputConstraintAdded(property, Max.class); }
@Command(value = "Digits", help = "Adds @Digits constraint on the specified property") public void addDigitsConstraint( @Option(name = "onProperty", completer = PropertyCompleter.class, required = true) String property, @Option(name = "onAccessor", flagOnly = true) boolean onAccessor, @Option(name = "integer", required = true) int integer, @Option(name = "fraction", required = true) int fraction, @Option(name = "message") String message, @Option(name = "groups", type = JAVA_CLASS) String[] groups) throws FileNotFoundException { final Annotation<JavaClass> constraintAnnotation = addConstraintOnProperty(property, onAccessor, Digits.class); setConstraintMessage(constraintAnnotation, message); constraintAnnotation.setLiteralValue("integer", String.valueOf(integer)); constraintAnnotation.setLiteralValue("fraction", String.valueOf(fraction)); javaSourceFacet.saveJavaSource(constraintAnnotation.getOrigin()); outputConstraintAdded(property, Digits.class); }
@Command(value = "DecimalMin", help = "Adds @DecimalMin constraint on the specified property") public void addDecimalMinConstraint( @Option(name = "onProperty", completer = PropertyCompleter.class, required = true) String property, @Option(name = "onAccessor", flagOnly = true) boolean onAccessor, @Option(name = "min", required = true) String min, @Option(name = "message") String message, @Option(name = "groups", type = JAVA_CLASS) String[] groups) throws FileNotFoundException { final Annotation<JavaClass> constraintAnnotation = addConstraintOnProperty(property, onAccessor, DecimalMin.class); setConstraintMessage(constraintAnnotation, message); constraintAnnotation.setStringValue(min); javaSourceFacet.saveJavaSource(constraintAnnotation.getOrigin()); outputConstraintAdded(property, DecimalMin.class); }
@Command(value = "DecimalMax", help = "Adds @DecimalMax constraint on the specified property") public void addDecimalMaxConstraint( @Option(name = "onProperty", completer = PropertyCompleter.class, required = true) String property, @Option(name = "onAccessor", flagOnly = true) boolean onAccessor, @Option(name = "max", required = true) String max, @Option(name = "message") String message, @Option(name = "groups", type = JAVA_CLASS) String[] groups) throws FileNotFoundException { final Annotation<JavaClass> constraintAnnotation = addConstraintOnProperty(property, onAccessor, DecimalMax.class); setConstraintMessage(constraintAnnotation, message); constraintAnnotation.setStringValue(max); javaSourceFacet.saveJavaSource(constraintAnnotation.getOrigin()); outputConstraintAdded(property, DecimalMax.class); }
@Command(value = "AssertFalse", help = "Adds @AssertFalse constraint on the specified property") public void addAssertFalseConstraint( @Option(name = "onProperty", completer = PropertyCompleter.class, required = true) String property, @Option(name = "onAccessor", flagOnly = true) boolean onAccessor, @Option(name = "message") String message, @Option(name = "groups", type = JAVA_CLASS) String[] groups) throws FileNotFoundException { final Annotation<JavaClass> constraintAnnotation = addConstraintOnProperty(property, onAccessor, AssertFalse.class); setConstraintMessage(constraintAnnotation, message); javaSourceFacet.saveJavaSource(constraintAnnotation.getOrigin()); outputConstraintAdded(property, AssertFalse.class); }
@DefaultCommand public void run( @Option(description = "The starting resource to be listed", defaultValue = ".") final Resource<?> r, PipeOut out) throws IOException { listResources(out, r); }
@Command(value = "Size", help = "Adds @Size constraint on the specified property") public void addSizeConstraint( @Option(name = "onProperty", completer = PropertyCompleter.class, required = true) String property, @Option(name = "onAccessor", flagOnly = true) boolean onAccessor, @Option(name = "min") Integer min, @Option(name = "max") Integer max, @Option(name = "message") String message, @Option(name = "groups", type = JAVA_CLASS) String[] groups) throws FileNotFoundException { final Annotation<JavaClass> constraintAnnotation = addConstraintOnProperty(property, onAccessor, Size.class); setConstraintMessage(constraintAnnotation, message); if (min != null) { constraintAnnotation.setLiteralValue("min", String.valueOf(min)); } if (max != null) { constraintAnnotation.setLiteralValue("max", String.valueOf(max)); } javaSourceFacet.saveJavaSource(constraintAnnotation.getOrigin()); outputConstraintAdded(property, Size.class); }
@DefaultCommand public void set(final PipeOut out, @Option(help = "The alias name to remove: E.g: 'mycommand'") final String[] aliases) { if ((aliases != null) && (aliases.length > 0)) { for (String alias : aliases) { registry.removeAlias(alias); } } } }
@Command("remove-facet") public void removeFacet(@Option(required = true, completer = InstalledFacetsCompleter.class, description = "Name of the facet to install") final String facetName) { try { Facet facet = factory.getFacetByName(facetName); removeFacets.fire(new RemoveFacets(facet.getClass())); } catch (FacetNotFoundException e) { throw new RuntimeException("Could not find a facet with the name: " + facetName + "; use 'project list-facets' to list all available facets.", e); } }