Skip to content

Commit

Permalink
Code cleanup to remove dependency to plexus-utils
Browse files Browse the repository at this point in the history
Closes #52
  • Loading branch information
slachiewicz committed Jan 9, 2024
1 parent 9e9d267 commit 1bb7afb
Show file tree
Hide file tree
Showing 11 changed files with 5 additions and 25 deletions.
6 changes: 0 additions & 6 deletions plexus-interactivity-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
<name>Plexus Default Interactivity Handler</name>

<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>4.0.0</version>
</dependency>

<!-- JLine is optional -->
<dependency>
<groupId>org.jline</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
* Base input handler, implements a default <code>readMultipleLines</code>.
*
* @author Brett Porter
* @version $Id$
*/
public abstract class AbstractInputHandler implements InputHandler {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
* Default input handler, that uses the console.
*
* @author Brett Porter
* @version $Id$
*/
@Named
public class DefaultInputHandler extends AbstractInputHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
* Default output handler, that uses the console.
*
* @author Brett Porter
* @version $Id$
*/
@Named
public class DefaultOutputHandler implements OutputHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,10 @@
import java.util.Iterator;
import java.util.List;

import org.codehaus.plexus.util.StringUtils;

/**
* Default prompter.
*
* @author Brett Porter
* @version $Id$
*/
@Named
public class DefaultPrompter implements Prompter {
Expand Down Expand Up @@ -76,11 +73,9 @@ public String prompt(String message, String defaultReply) throws PrompterExcepti

try {
String line = inputHandler.readLine();

if (StringUtils.isEmpty(line)) {
if (line == null || line.isEmpty()) {
line = defaultReply;
}

return line;
} catch (IOException e) {
throw new PrompterException("Failed to read user response", e);
Expand Down Expand Up @@ -109,7 +104,7 @@ public String prompt(String message, List<String> possibleValues, String default
throw new PrompterException("Failed to read user response", e);
}

if (StringUtils.isEmpty(line)) {
if (line == null || line.isEmpty()) {
line = defaultReply;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@

/**
* Manage user input from different sources.
*
* TODO should this also echo any prompts before the input?
* TODO should this validate the input, reprompt if required?
* TODO readBoolean, readInt, readSingleChar - readLine's that parse the input
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public interface InputHandler {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
* Manage user output to different sources.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public interface OutputHandler {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
* Prompt the user for input.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public interface Prompter {
String prompt(String message) throws PrompterException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* Error while prompting.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public class PrompterException extends Exception {
public PrompterException(String message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,16 @@
* Default input handler, that uses the console.
*
* @author Brett Porter
* @version $Id$
*/
@Named("jline")
public class JLineInputHandler extends AbstractInputHandler {
private LineReader consoleReader = LineReaderBuilder.builder().build();
private final LineReader consoleReader = LineReaderBuilder.builder().build();

public String readLine() throws IOException {
return consoleReader.readLine();
}

public String readPassword() throws IOException {
return consoleReader.readLine(new Character('*'));
return consoleReader.readLine('*');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class DefaultPrompterComponentTest extends InjectedTest {
private Prompter prompter;

@Test
void smoke() throws PrompterException {
void smoke() {
assertNotNull(prompter);
}
}

0 comments on commit 1bb7afb

Please sign in to comment.