protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl) throws Exception { String path = (String) cl.getValue(argPath); int depth = Integer.MAX_VALUE; if (cl.hasOption(optRecursive)) { depth = ((Long) cl.getValue(optRecursive)).intValue(); } ConsoleFile file = ctx.getFile(path, true); tree(file, depth, ""); }
protected static void maybePut(Map<String, List<String>> args, CommandLine cmdLine, Option... opt) { for (Option o : opt) { // the option appeared on the command-line, or it has a value // (which is likely a default value). if (cmdLine.hasOption(o) || cmdLine.getValue(o) != null || (cmdLine.getValues(o) != null && !cmdLine.getValues(o).isEmpty())) { // nulls are ok, for cases where options are simple flags. List<?> vo = cmdLine.getValues(o); if (vo != null && !vo.isEmpty()) { List<String> vals = Lists.newArrayList(); for (Object o1 : vo) { vals.add(o1.toString()); } args.put(o.getPreferredName(), vals); } else { args.put(o.getPreferredName(), null); } } } }
public void execute(CommandLine cl) throws ExecutionException { if (cl.hasOption(optVersion)) { printVersion(); //} else if (cl.hasOption(optInteractive)) { // getConsole().run(); } else if (cl.hasOption(optHelp)) { String cmd = (String) cl.getValue(optHelp); if (cmd == null) { // in this case, the --help is specified after the command // eg: vlt checkout --help Iterator iter = cl.getOptions().iterator(); while (iter.hasNext()) { Object o = iter.next(); if (o instanceof Command) { cmd = ((Command) o).getPreferredName(); break; } } } printHelp(cmd); } else { if (!getDefaultContext().execute(cl)) { log.error("Unknown command. Type '--help' for more information."); } } }
@SuppressWarnings("unchecked") protected void doExecute(VaultFsApp app, CommandLine cl) throws Exception { List<String> localPaths = cl.getValues(argLocalPath); List<File> localFiles = app.getPlatformFiles(localPaths, false); File localDir = app.getPlatformFile("", true); VltContext vCtx = app.createVaultContext(localDir); vCtx.setVerbose(cl.hasOption(OPT_VERBOSE)); vCtx.setQuiet(cl.hasOption(OPT_QUIET)); Add a = new Add(localDir, localFiles, cl.hasOption(optNonRecursive), cl.hasOption(optForce)); vCtx.execute(a); }
static String getString(CommandLine commandLine, Option option) { Object val = commandLine.getValue(option); if (val != null) { return val.toString(); } return null; }
protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl) throws Exception { String jcrPath = (String) cl.getValue(argJcrPath); List added = cl.getValues(optAdd); List rems = cl.getValues(optRemove); ConsoleFile wo = ctx.getFile(jcrPath, true); if (wo instanceof RepositoryCFile) { Node node = (Node) wo.unwrap(); try { for (Iterator it = added.iterator(); it.hasNext();) { node.addMixin((String) it.next()); } for (Iterator it = rems.iterator(); it.hasNext();) { node.removeMixin((String) it.next()); } String delim = "Mixins: "; for (NodeType nt: node.getMixinNodeTypes()) { System.out.print(delim); System.out.print(nt.getName()); delim = ", "; } System.out.println(); } catch (RepositoryException e) { throw new ExecutionException("Error while downloading file: " + e); } } else { throw new ExecutionException("'mixins' only possible in repcontext"); } }
static List<String> getStringList(CommandLine commandLine, Option option) { return commandLine.getValues(option); }
@SuppressWarnings("unchecked") protected void doExecute(VaultFsApp app, CommandLine cl) throws Exception { List<String> localPaths = cl.getValues(argLocalPath); List<File> localFiles = app.getPlatformFiles(localPaths, false); File localDir = app.getPlatformFile("", true); VltContext vCtx = app.createVaultContext(localDir); vCtx.setVerbose(cl.hasOption(OPT_VERBOSE)); vCtx.setQuiet(cl.hasOption(optOnlyControlled)); Action a = cl.hasOption(optShowUpdate) ? new RemoteStatus(localDir, localFiles, cl.hasOption(optNonRecursive)) : new Status(localDir, localFiles, cl.hasOption(optNonRecursive)); vCtx.execute(a); }
public Object getOptionValue(String optName) { if (cmdLine == null) throw new IllegalStateException(); return this.cmdLine.getValue(optName); }
protected int getFormatFlags(VaultFsConsoleExecutionContext ctx, CommandLine cl) { int fmtFlag = 0; fmtFlag |= cl.hasOption(optTime) ? F_FLAG_TIME : 0; fmtFlag |= cl.hasOption(optSize) ? F_FLAG_SIZE : 0; fmtFlag |= cl.hasOption(optMime) ? F_FLAG_MIME : 0; fmtFlag |= cl.hasOption(optLong) ? F_FLAG_LONG : 0; return fmtFlag; }
static List<Integer> getIntegerList(CommandLine commandLine, Option option) { List<String> list = commandLine.getValues(option); List<Integer> valList = Lists.newArrayList(); for (String str : list) { valList.add(Integer.parseInt(str)); } return valList; }
protected void doExecute(ConsoleExecutionContext ctx, CommandLine cl) throws Exception { int fmtFlag = 0; fmtFlag |= cl.hasOption(optTime) ? F_FLAG_TIME : 0; fmtFlag |= cl.hasOption(optSize) ? F_FLAG_SIZE : 0; fmtFlag |= cl.hasOption(optLong) ? F_FLAG_LONG : 0; fmtFlag |= cl.hasOption(optAll) ? L_FLAG_ALL : 0; int depth = 0; if (cl.hasOption(optRecursive)) { depth = Integer.parseInt((String) cl.getValue(optRecursive, "10000")); } String path = (String) cl.getValue(argPath); ConsoleFile file = ctx.getFile(path, true); if (!(file instanceof PlatformFile)) { throw new ExecutionException("wrong file system."); } ls((PlatformFile) file, fmtFlag, depth); }
protected static void maybePut(Map<String, List<String>> args, CommandLine cmdLine, Option... opt) { for (Option o : opt) { // the option appeared on the command-line, or it has a value // (which is likely a default value). if (cmdLine.hasOption(o) || cmdLine.getValue(o) != null || (cmdLine.getValues(o) != null && !cmdLine.getValues(o).isEmpty())) { // nulls are ok, for cases where options are simple flags. List<?> vo = cmdLine.getValues(o); if (vo != null && !vo.isEmpty()) { List<String> vals = Lists.newArrayList(); for (Object o1 : vo) { vals.add(o1.toString()); } args.put(o.getPreferredName(), vals); } else { args.put(o.getPreferredName(), null); } } } }
@SuppressWarnings("unchecked") protected void doExecute(VaultFsApp app, CommandLine cl) throws Exception { List<String> localPaths = cl.getValues(argLocalPath); List<File> localFiles = app.getPlatformFiles(localPaths, false); File localDir = app.getPlatformFile("", true); VltContext vCtx = app.createVaultContext(localDir); vCtx.setVerbose(cl.hasOption(OPT_VERBOSE)); vCtx.setQuiet(cl.hasOption(OPT_QUIET)); Commit s = new Commit(localDir, localFiles, cl.hasOption(optNonRecursive), cl.hasOption(optForce)); vCtx.execute(s); }
public Object getOptionValue(Option opt) { if (cmdLine == null) throw new IllegalStateException(); return this.cmdLine.getValue(opt); }
protected int getFormatFlags(VaultFsConsoleExecutionContext ctx, CommandLine cl) { int fmtFlag = 0; fmtFlag |= cl.hasOption(optType) ? F_FLAG_TYPE : 0; return fmtFlag; }
if (inputOption != null && cmdLine.hasOption(inputOption)) { this.inputPath = new Path(cmdLine.getValue(inputOption).toString()); this.inputFile = new File(cmdLine.getValue(inputOption).toString()); if (outputOption != null && cmdLine.hasOption(outputOption)) { this.outputPath = new Path(cmdLine.getValue(outputOption).toString()); this.outputFile = new File(cmdLine.getValue(outputOption).toString());
protected static void maybePut(Map<String, List<String>> args, CommandLine cmdLine, Option... opt) { for (Option o : opt) { // the option appeared on the command-line, or it has a value // (which is likely a default value). if (cmdLine.hasOption(o) || cmdLine.getValue(o) != null || (cmdLine.getValues(o) != null && !cmdLine.getValues(o).isEmpty())) { // nulls are ok, for cases where options are simple flags. List<?> vo = cmdLine.getValues(o); if (vo != null && !vo.isEmpty()) { List<String> vals = new ArrayList<>(); for (Object o1 : vo) { vals.add(o1.toString()); } args.put(o.getPreferredName(), vals); } else { args.put(o.getPreferredName(), null); } } } }