/** * Resolves the first argument of a command line into either a unique identifier * * @param inputLine * @return */ protected Identifiable findItem(InputLine inputLine) { // first case is one in which this does not apply since there is no argument. if (inputLine.size() <= 1) { return null; } if (inputLine.getLastArg().startsWith("/")) { // then try to process this as a unique identifier. String arg = inputLine.getLastArg().substring(1); Identifier id = BasicIdentifier.newID(arg); return (Identifiable) getStore().get(id); } int choice = inputLine.getIntArg(inputLine.size() - 1); if (allEntries == null || allEntries.isEmpty()) { loadAllEntries(); // just in case... } return allEntries.get(choice); }
public void create_hash(InputLine inputLine) { if (showHelp(inputLine)) { showCreateHashHelp(); return; } String secret = null; if (inputLine.hasArg("-file")) { try { FileReader fis = new FileReader(inputLine.getArg(1 + inputLine.indexOf("-file"))); StringBuffer sb = new StringBuffer(); int i; while ((i = fis.read()) != -1) { sb.append((char) i); } fis.close(); secret = sb.toString(); } catch (Throwable t) { say("Error: could not read file: " + t.getMessage()); return; } } else { secret = inputLine.getLastArg(); } say("creating hash of " + secret); say(DigestUtils.sha1Hex(secret)); }
if (!inputLine.getLastArg().startsWith("-")) { Identifiable identifiable = findItem(inputLine); if (identifiable == null) {
values = getStore().search(key, inputLine.getLastArg(), inputLine.hasArg(REGEX_FLAG)); }catch(Throwable t){ say("Sorry, that didn't work:" + t.getMessage());