@Command // CHECKSTYLE:OFF public void rsync(@Option("recursive") final boolean recursive, @Option("links") final boolean links, @Option("perms") final boolean perms, @Option("owner") final boolean owner, @Option("group") final boolean group, @Option("devices") final boolean devices, @Option("specials") final boolean specials, @Option("times") final boolean times, @Option("exclude") final Pattern exclude, @Option("exclude-from") final File excludeFrom, @Option("include") final Pattern include, @Option("include-from") final File includeFrom, @Option("progress") @Default("true") final boolean progress, final URI[] sources, final URI dest) { // TODO write the implementation... } }
@Command public String home() { return System.getProperty("user.home"); }
@Command("set") public String doSet(@Option({"key", "k"}) String key, @Option({"value", "v"}) String value) { final Object old = properties.setProperty(key, value); final StringBuilder sb = new StringBuilder(); sb.append("set ").append(key).append(" to ").append(value); sb.append("\n"); if (old != null) { sb.append("old value: ").append(old); sb.append("\n"); } return sb.toString(); }
public static String name(final Method method) { final Command command = method.getAnnotation(Command.class); if (command == null) { return method.getName(); } return value(command.value(), method.getName()); }
@Command public String dir() { return System.getProperty("user.dir"); }
@Command("get") public String doGet(String key) { return properties.getProperty(key); }
@Command public void gc() { Runtime.getRuntime().gc(); }
@Command public int processors() { return Runtime.getRuntime().availableProcessors(); }
@Command public String date() { return String.format("%tc", System.currentTimeMillis()); }
@Command public void exit() throws StopException { throw new StopException(); } }
@Command public void exit() throws StopException { throw new StopException(); } }
@Command public String whoami() { return context.getCallerPrincipal() == null ? "Unknown" : context.getCallerPrincipal().getName(); } }
@Command public StreamingOutput cat(@IsFile @Readable final File file) { return new StreamingOutput() { @Override public void write(final OutputStream os) throws IOException { IO.copy(file, os); } }; }
@Command public static void clear(final CliEnvironment env) { env.reader().clear(); }