static public List<String> commandExtensions(Config config) { if (OperatingSystem.windows()) { return config.value(Config.KEY_COMMAND_EXTS, List.class).getOr(Config.DEFAULT_COMMAND_EXTS_WINDOWS); } else { return config.value(Config.KEY_COMMAND_EXTS, List.class).getOr(Config.DEFAULT_COMMAND_EXTS_UNIX); } }
static public <T> Value<T> of(String key, T value) { return new Value(key, value); }
/** * The application base directory. The base directory is the directory * of the script that is executing. So if your script is located at * "/home/joelauer/project/blaze.java" then this baes directory would be * "/home/joelauer/project" * @return The application base directory */ static public Path baseDir() { return ContextHolder.get().baseDir(); }
public void execute(String task) throws Exception { if (task == null || task.equals("")) { task = context.config().value(Config.KEY_DEFAULT_TASK).getOr(Config.DEFAULT_TASK); } String scriptName = (context.scriptFile() != null ? context.scriptFile().toString() : ""); log.info("Executing {}:{}...", scriptName, task); Timer executeTimer = new Timer(); this.script.execute(task); log.info("Executed {}:{} in {} ms", scriptName, task, executeTimer.stop().millis()); }
/** * The current user's home directory such as "/home/joelauer" or "C:\Users\Joe Lauer". * This method differs from <code>System.getProperty("user.home")</code> by * checking the environment variables HOME and HOMEPATH first. This allows * a program running under something like "sudo" to still correctly find * the actual user's home directory rather than "root". * * @return The current user's home directory */ static public Path userDir() { return ContextHolder.get().userDir(); }
static public Path userBlazeDir(Context context) throws IOException { Path userBlazeDir = context.withUserDir(".blaze"); if (Files.notExists(userBlazeDir)) { Files.createDirectory(userBlazeDir); } return userBlazeDir; }
@Override public boolean promptYesNo(String prompt) { // fix prompt for host key if (prompt.contains("authenticity of host") && prompt.endsWith("connecting?")) { prompt = prompt.substring(0, prompt.length() - 1); prompt += " (yes/no)?"; } String answer = Contexts.prompt(prompt + " "); return answer.equalsIgnoreCase("yes"); }
@Override public String getPassphrase() { String prompt = String.format("identity passphrase: "); char[] password = Contexts.passwordPrompt(prompt); // THIS IS UNFORTUNATE SINCE THIS STRING IS INTERNED... return new String(password); }
static public List<String> commandExtensions(Config config) { if (OperatingSystem.windows()) { return config.value(Config.KEY_COMMAND_EXTS, List.class).getOr(Config.DEFAULT_COMMAND_EXTS_WINDOWS); } else { return config.value(Config.KEY_COMMAND_EXTS, List.class).getOr(Config.DEFAULT_COMMAND_EXTS_UNIX); } }
/** * The application base directory. The base directory is the directory * of the script that is executing. So if your script is located at * "/home/joelauer/project/blaze.java" then this baes directory would be * "/home/joelauer/project" * @return The application base directory */ static public Path baseDir() { return ContextHolder.get().baseDir(); }
static public <T> Value<T> of(String key, T value) { return new Value(key, value); }
static public <T> Value<T> empty(String key) { return new Value(key, null); }
static public <T> Value<T> empty(String key) { return new Value(key, null); }