public void rewindBuffer(final int height, final int toLine) { int renderFrom = toLine - height; if (renderFrom < 0) { bufferLine = 0; bufferPos = 0; } else { bufferPos = findLine(renderFrom); bufferLine = renderFrom; } }
private static String attr(int... code) { return new String(new char[] { 27, '[' }) + _attr(code) + "m"; }
List<String> getResults(String name) { int cols = getColumns(); List<String> results = new ArrayList<String>(cols); for (int i = 0; i < cols - 1; i++) { results.add(" " + String.valueOf(getValue(i))); } results.add(name); return results; } }
@DefaultCommand public void copy( @Option(description = "source", required = true) final Resource<?> source, @Option(description = "target", required = true) final String target) { if (isDirectory(source)) { copyRecursively(source, directory, target); } else if (isFile(source)) { copy(source, directory, target); } else { throw new RuntimeException("cannot copy resource type: " + source.getClass().getSimpleName()); } }
LineBuffer lineBuffer = new LineBuffer(stream, width); StringBuilder lastPattern = new StringBuilder(); Mainloop: while ((read = lineBuffer.read(buffer)) != -1) lineBuffer.seenLine(); lCounter = width; ++y; continue Bufferloop; case '\n': lineBuffer.seenLine(); lCounter = width; if (++y == 1) switch (prompt(lineBuffer, out, lastPattern)) switch (prompt(lineBuffer, out, lastPattern))
@DefaultCommand public void run( @Option(help = "The text to be echoed") final String[] tokens, final PipeOut out) { if (tokens == null || tokens.length == 0) { return; } out.println(echo(shell, promptExpressionParser(shell, tokensToString(tokens)))); }
@Override public String getPrompt() { if (projectContext.getCurrent() != null) { return Echo.echo(this, Echo.promptExpressionParser(this, (String) environment.getProperty(PROP_PROMPT))); } else { return Echo.echo(this, Echo.promptExpressionParser(this, (String) environment.getProperty(PROP_PROMPT_NO_PROJ))); } }
@DefaultCommand public void run(@Option(description = "varname", completer = EnvironmentPropertiesCompleter.class) final String variable, @Option(description = "value") final String... value) { if (variable == null) { listVars(); } else { if (value == null) { forge.removeProperty(variable); } else { forge.setProperty(variable, Echo.tokensToString(value)); } } }
@DefaultCommand public void run( @Option(description = "The starting resource to be listed", defaultValue = ".") final Resource<?> r, PipeOut out) throws IOException { listResources(out, r); }
@DefaultCommand public void run(PipeOut out) { forge.about(out); } }
void pickup(@Observes final PickupResource event) { run(event.getResource(), null); }
int read; Results res = new Results(); res.countLines = lines; res.countWords = words;
@DefaultCommand public void run(@PipeIn InputStream pipeIn, final Resource<?> file, final PipeOut pipeOut) throws IOException { morePlugin.run(pipeIn, file, true, pipeOut); } }
@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); } } } }
@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 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); } }
private void copy(final Resource<?> source, Resource<?> directory, final String target) { List<Resource<?>> results = new PathspecParser(resourceFactory, directory, target).resolve(); if (results.size() > 1) { throw new RuntimeException("ambiguous target file name: " + target); } else { Resource<?> targetResource = results.get(0); if (targetResource.exists()) { if (isDirectory(targetResource)) { targetResource = targetResource.getChild(source.getName()); } } ((FileResource<?>) targetResource).setContents(source.getResourceInputStream()); } }
@Command(value = "remove-plugin", help = "Removes a plugin from the current Forge runtime configuration") public void removePlugin( @Option(completer = InstalledPluginCompleter.class, description = "plugin-name", required = true, help = "The fully qualified plugin name e.g: 'org.jboss.forge.plugin:version'") final String pluginName, final PipeOut out) throws Exception { if (pluginManager.removePlugin(pluginName)) { ShellMessages.success(out, "Successfully removed [" + pluginName + "]"); restart(); } else { ShellMessages.error(out, "Failed to remove [" + pluginName + ""); } }
private void listResources(PipeOut out, Resource<?> r) { List<Resource<?>> list = r.listResources(); out.println(r.getFullyQualifiedName()); if (list != null && !list.isEmpty()) { for (Resource<?> resource : list) { listResources(out, resource); } } } }