/** * Moves the console cursor to the beginning of the line (prints a carriage return {@code '\r'} * character) and redraws the contents of the cursor buffer. * * @throws IOException */ public void redrawLine() throws IOException { cursorBuffer.append(CARRIAGE_RETURN); flush(); }
/** * Moves the console cursor to the beginning of the line (prints a carriage return {@code '\r'} * character) and redraws the contents of the cursor buffer. * * @throws IOException */ public void redrawLine() throws IOException { cursorBuffer.append(CARRIAGE_RETURN); flush(); }
/** * Moves the console cursor to the beginning of the line (prints a carriage * return {@code '\r'} character) and redraws the contents of the cursor buffer. * * @throws IOException */ public void redrawLine() throws IOException { cursorBuffer.append(CARRIAGE_RETURN); cursorBuffer.append(CLEAR_LINE); flush(); }
/** * Prints the {@code line} text to the console and starts a new line, flushing * the cursor buffer. * * @param line the text to write * @throws IOException */ public synchronized void println(CharSequence line) throws IOException { print(line); cursorBuffer.append("\n"); flush(); }
/** * Prints the {@code line} text to the console and starts a new line, flushing the cursor * buffer. * * @param line the text to write * @throws IOException */ public synchronized void println(CharSequence line) throws IOException { print(line); cursorBuffer.append("\n"); flush(); }
/** * Prints the {@code line} text to the console and starts a new line, flushing the cursor * buffer. * * @param line the text to write * @throws IOException */ public synchronized void println(CharSequence line) throws IOException { print(line); cursorBuffer.append("\n"); flush(); }
/** * This method should be used instead of {@link JCommander#usage()} so the help string is * printed to the cli's {@link #getConsole() console} (and hence to wherever its output is sent) * instead of directly to {@code System.out} */ public void printUsage(JCommander mainCommander) { StringBuilder out = new StringBuilder(); mainCommander.usage(out); Console console = getConsole(); try { console.println(out.toString()); console.flush(); } catch (IOException e) { throw new RuntimeException(e); } }
/** * This method should be used instead of {@link JCommander#usage()} so the help string is * printed to the cli's {@link #getConsole() console} (and hence to wherever its output is sent) * instead of directly to {@code System.out} */ public void printUsage(JCommander mainCommander) { StringBuilder out = new StringBuilder(); mainCommander.usage(out); Console console = getConsole(); try { console.println(out.toString()); console.flush(); } catch (IOException e) { throw Throwables.propagate(e); } }
/** * This method should be used instead of {@link JCommander#usage()} so the help string is * printed to the cli's {@link #getConsole() console} (and hence to wherever its output is sent) * instead of directly to {@code System.out} */ public void printUsage(JCommander mainCommander) { StringBuilder out = new StringBuilder(); mainCommander.usage(out); Console console = getConsole(); try { console.println(out.toString()); console.flush(); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public void runInternal(final GeogigCLI cli) throws IOException { String ref; if (refList.isEmpty()) { ref = null; } else { ref = refList.get(0); } final Function<Object, CharSequence> printFunctor = verbose ? VERBOSE_FORMATTER : FORMATTER; Console console = cli.getConsole(); Listener listener = new PrintListener(console, printFunctor); try { cli.getGeogig().command(WalkGraphOp.class).setReference(ref).setListener(listener) .call(); } catch (IllegalArgumentException | IllegalStateException e) { throw new CommandFailedException(e.getMessage(), true); } finally { console.flush(); } }
@Override public void runInternal(final GeogigCLI cli) throws IOException { String ref; if (refList.isEmpty()) { ref = null; } else { ref = refList.get(0); } final Function<Object, CharSequence> printFunctor = verbose ? VERBOSE_FORMATTER : FORMATTER; Console console = cli.getConsole(); Listener listener = new PrintListener(console, printFunctor); try { cli.getGeogig().command(WalkGraphOp.class).setReference(ref).setListener(listener) .call(); } catch (IllegalArgumentException | IllegalStateException e) { throw new CommandFailedException(e.getMessage(), true); } finally { console.flush(); } }
@Override public void runInternal(final GeogigCLI cli) throws IOException { String ref; if (refList.isEmpty()) { ref = null; } else { ref = refList.get(0); } final Function<Object, CharSequence> printFunctor = verbose ? VERBOSE_FORMATTER : FORMATTER; Console console = cli.getConsole(); Listener listener = new PrintListener(console, printFunctor); try { cli.getGeogig().command(WalkGraphOp.class).setReference(ref).setListener(listener) .call(); } catch (IllegalArgumentException | IllegalStateException e) { throw new CommandFailedException(e.getMessage(), true); } finally { console.flush(); } }
@Test public void testFlushException() throws Exception { doThrow(new IOException("Exception")).when(consoleReader).flush(); PGDescribe describeCommand = new PGDescribe(); describeCommand.table = "table1"; describeCommand.support.dataStoreFactory = TestHelper.createTestFactory(); exception.expect(Exception.class); describeCommand.run(cli); } }
@Test public void testFlushException() throws Exception { doThrow(new IOException("Exception")).when(consoleReader).flush(); GeopkgDescribe describeCommand = new GeopkgDescribe(); describeCommand.commonArgs.database = support.newFile().getAbsolutePath(); describeCommand.table = "table1"; describeCommand.support.dataStoreFactory = TestHelper.createTestFactory(); exception.expect(Exception.class); describeCommand.run(cli); }
@Test public void testFlushException() throws Exception { doThrow(new IOException("Exception")).when(consoleReader).flush(); PGDescribe describeCommand = new PGDescribe(); describeCommand.table = "table1"; describeCommand.support.dataStoreFactory = TestHelper.createTestFactory(); exception.expect(Exception.class); describeCommand.run(cli); } }
@Test public void testFlushException() throws Exception { doThrow(new IOException("Exception")).when(consoleReader).flush(); GeopkgDescribe describeCommand = new GeopkgDescribe(); describeCommand.commonArgs.database = support.newFile().getAbsolutePath(); describeCommand.table = "table1"; describeCommand.support.dataStoreFactory = TestHelper.createTestFactory(); exception.expect(Exception.class); describeCommand.run(cli); }
@Test public void testFlushException() throws Exception { Console consoleReader = cli.getConsole(); doThrow(new IOException("Exception")).when(consoleReader).flush(); OracleDescribe describeCommand = new OracleDescribe(); describeCommand.table = "table1"; describeCommand.support.dataStoreFactory = TestHelper.createTestFactory(); exception.expect(Exception.class); describeCommand.run(cli); } }
/** * Executes the list command using the provided options. */ @Override protected void runInternal(GeogigCLI cli) throws IOException { DataStore dataStore = getDataStore(); try { cli.getConsole().println("Fetching feature types..."); Optional<List<String>> features = cli.getGeogig().command(ListOp.class) .setDataStore(dataStore).call(); if (features.isPresent()) { for (String featureType : features.get()) { cli.getConsole().println(" - " + featureType); } } else { throw new CommandFailedException( "No features types were found in the specified database."); } } catch (GeoToolsOpException e) { throw new CommandFailedException("Unable to get feature types from the database.", e); } finally { dataStore.dispose(); cli.getConsole().flush(); } } }
/** * Executes the list command using the provided options. */ @Override protected void runInternal(GeogigCLI cli) throws IOException { DataStore dataStore = getDataStore(); try { cli.getConsole().println("Fetching feature types..."); Optional<List<String>> features = cli.getGeogig().command(ListOp.class) .setDataStore(dataStore).call(); if (features.isPresent()) { for (String featureType : features.get()) { cli.getConsole().println(" - " + featureType); } } else { throw new CommandFailedException( "No features types were found in the specified database."); } } catch (GeoToolsOpException e) { throw new CommandFailedException("Unable to get feature types from the database.", e); } finally { dataStore.dispose(); cli.getConsole().flush(); } } }
/** * Executes the list command using the provided options. */ @Override protected void runInternal(GeogigCLI cli) throws IOException { DataStore dataStore = getDataStore(); try { cli.getConsole().println("Fetching feature types..."); Optional<List<String>> features = cli.getGeogig().command(ListOp.class) .setDataStore(dataStore).call(); if (features.isPresent()) { for (String featureType : features.get()) { cli.getConsole().println(" - " + featureType); } } else { throw new CommandFailedException( "No features types were found in the specified database."); } } catch (GeoToolsOpException e) { throw new CommandFailedException("Unable to get feature types from the database.", e); } finally { dataStore.dispose(); cli.getConsole().flush(); } } }