public void setLog(File log) throws IOException { IO.mkdirs(log.getParentFile()); reporter = new ReporterAdapter(IO.writer(log)); }
public void setLog(File log) throws IOException { IO.mkdirs(log.getParentFile()); reporter = new ReporterAdapter(IO.writer(log)); }
/** * Initialize the repository Subclasses should first call this method and * then if it returns true, do their own initialization * * @return true if initialized, false if already had been initialized. * @throws Exception */ protected boolean init() throws Exception { if (inited) return false; inited = true; if (reporter == null) { ReporterAdapter reporter = trace ? new ReporterAdapter(System.out) : new ReporterAdapter(); reporter.setTrace(trace); reporter.setExceptions(trace); this.reporter = reporter; } if (!root.isDirectory()) { root.mkdirs(); if (!root.isDirectory()) throw new IllegalArgumentException("Location cannot be turned into a directory " + root); exec(init, root.getAbsolutePath()); } open(); return true; }
/** * Initialize the repository Subclasses should first call this method and * then if it returns true, do their own initialization * * @return true if initialized, false if already had been initialized. * @throws Exception */ protected boolean init() throws Exception { if (inited) return false; inited = true; if (reporter == null) { ReporterAdapter reporter = trace ? new ReporterAdapter(System.out) : new ReporterAdapter(); reporter.setTrace(trace); reporter.setExceptions(trace); this.reporter = reporter; } reporter.trace("init"); if (!root.isDirectory()) { root.mkdirs(); if (!root.isDirectory()) throw new IllegalArgumentException("Location cannot be turned into a directory " + root); exec(init, root.getAbsolutePath()); } if (hasIndex) index = new PersistentMap<ResourceDescriptor>(new File(root, ".index"), ResourceDescriptor.class); open(); return true; }
/** * Initialize the repository Subclasses should first call this method and * then if it returns true, do their own initialization * * @return true if initialized, false if already had been initialized. * @throws Exception */ protected boolean init() throws Exception { if (inited) return false; inited = true; if (reporter == null) { ReporterAdapter reporter = trace ? new ReporterAdapter(System.out) : new ReporterAdapter(); reporter.setTrace(trace); reporter.setExceptions(trace); this.reporter = reporter; } reporter.trace("init"); if (!root.isDirectory()) { root.mkdirs(); if (!root.isDirectory()) throw new IllegalArgumentException("Location cannot be turned into a directory " + root); exec(init, root.getAbsolutePath()); } if (hasIndex) index = new PersistentMap<ResourceDescriptor>(new File(root, ".index"), ResourceDescriptor.class); open(); return true; }
/** * Initialize the repository Subclasses should first call this method and * then if it returns true, do their own initialization * * @return true if initialized, false if already had been initialized. * @throws Exception */ protected boolean init() throws Exception { if (inited) return false; inited = true; if (reporter == null) { ReporterAdapter reporter = trace ? new ReporterAdapter(System.out) : new ReporterAdapter(); reporter.setTrace(trace); reporter.setExceptions(trace); this.reporter = reporter; } logger.debug("init"); if (!root.isDirectory()) { IO.mkdirs(root); if (!root.isDirectory()) throw new IllegalArgumentException("Location cannot be turned into a directory " + root); exec(init, IO.absolutePath(root)); } if (hasIndex) index = new PersistentMap<>(new File(root, ".index"), ResourceDescriptor.class); open(); return true; }
/** * Initialize the repository Subclasses should first call this method and * then if it returns true, do their own initialization * * @return true if initialized, false if already had been initialized. * @throws Exception */ protected boolean init() throws Exception { if (inited) return false; inited = true; if (reporter == null) { ReporterAdapter reporter = trace ? new ReporterAdapter(System.out) : new ReporterAdapter(); reporter.setTrace(trace); reporter.setExceptions(trace); this.reporter = reporter; } logger.debug("init"); if (!root.isDirectory()) { IO.mkdirs(root); if (!root.isDirectory()) throw new IllegalArgumentException("Location cannot be turned into a directory " + root); exec(init, IO.absolutePath(root)); } if (hasIndex) index = new PersistentMap<>(new File(root, ".index"), ResourceDescriptor.class); open(); return true; }
@Description("Generate autocompletion file for bash") public void _bash(Options options) throws Exception { File tmp = File.createTempFile("bnd-completion", ".tmp"); tmp.deleteOnExit(); try { IO.copy(getClass().getResource("bnd-completion.bash"), tmp); Sed sed = new Sed(tmp); sed.setBackup(false); Reporter r = new ReporterAdapter(); CommandLine c = new CommandLine(r); Map<String,Method> commands = c.getCommands(this); StringBuilder sb = new StringBuilder(); for (String commandName : commands.keySet()) { sb.append(" " + commandName); } sb.append(" help"); sed.replace("%listCommands%", sb.toString().substring(1)); sed.doIt(); IO.copy(tmp, out); } finally { tmp.delete(); } }