plexus-interactivity-api/0000755000175000017500000000000010632266573014537 5ustar paulpaulplexus-interactivity-api/pom.xml0000644000175000017500000000132610603302041016031 0ustar paulpaul plexus-interactivity org.codehaus.plexus 1.0-alpha-6 4.0.0 plexus-interactivity-api Plexus Default Interactivity Handler 1.0-alpha-6 org.codehaus.plexus plexus-utils 1.4 plexus-interactivity-api/src/0000755000175000017500000000000010632266571015324 5ustar paulpaulplexus-interactivity-api/src/main/0000755000175000017500000000000010632266572016251 5ustar paulpaulplexus-interactivity-api/src/main/resources/0000755000175000017500000000000010632266572020263 5ustar paulpaulplexus-interactivity-api/src/main/resources/META-INF/0000755000175000017500000000000010632266572021423 5ustar paulpaulplexus-interactivity-api/src/main/resources/META-INF/plexus/0000755000175000017500000000000010632266572022743 5ustar paulpaulplexus-interactivity-api/src/main/resources/META-INF/plexus/components.xml0000644000175000017500000000255310572050411025641 0ustar paulpaul org.codehaus.plexus.components.interactivity.InputHandler default org.codehaus.plexus.components.interactivity.DefaultInputHandler per-lookup org.codehaus.plexus.components.interactivity.OutputHandler default org.codehaus.plexus.components.interactivity.DefaultOutputHandler per-lookup org.codehaus.plexus.components.interactivity.Prompter default org.codehaus.plexus.components.interactivity.DefaultPrompter per-lookup org.codehaus.plexus.components.interactivity.InputHandler default org.codehaus.plexus.components.interactivity.OutputHandler default plexus-interactivity-api/src/main/java/0000755000175000017500000000000010632266571017171 5ustar paulpaulplexus-interactivity-api/src/main/java/org/0000755000175000017500000000000010632266571017760 5ustar paulpaulplexus-interactivity-api/src/main/java/org/codehaus/0000755000175000017500000000000010632266571021553 5ustar paulpaulplexus-interactivity-api/src/main/java/org/codehaus/plexus/0000755000175000017500000000000010632266571023073 5ustar paulpaulplexus-interactivity-api/src/main/java/org/codehaus/plexus/components/0000755000175000017500000000000010632266571025260 5ustar paulpaulplexus-interactivity-api/src/main/java/org/codehaus/plexus/components/interactivity/0000755000175000017500000000000010632266572030157 5ustar paulpaul././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootplexus-interactivity-api/src/main/java/org/codehaus/plexus/components/interactivity/PrompterException.javaplexus-interactivity-api/src/main/java/org/codehaus/plexus/components/interactivity/PrompterExceptio0000644000175000017500000000312510322516047033403 0ustar paulpaulpackage org.codehaus.plexus.components.interactivity; /* * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ /** * Error while prompting. * * @author Brett Porter * @version $Id: PrompterException.java 2649 2005-10-10 16:51:51Z brett $ */ public class PrompterException extends Exception { public PrompterException( String message ) { super( message ); } public PrompterException( String message, Throwable cause ) { super( message, cause ); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootplexus-interactivity-api/src/main/java/org/codehaus/plexus/components/interactivity/OutputHandler.javaplexus-interactivity-api/src/main/java/org/codehaus/plexus/components/interactivity/OutputHandler.ja0000644000175000017500000000347210322516047033266 0ustar paulpaulpackage org.codehaus.plexus.components.interactivity; /* * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ import java.io.IOException; /** * Manage user output to different sources. * * @author Brett Porter * @version $Id: OutputHandler.java 2649 2005-10-10 16:51:51Z brett $ */ public interface OutputHandler { String ROLE = OutputHandler.class.getName(); /** * Write a single line of input, excluding the newline at the end. * @param line the line */ void write( String line ) throws IOException; /** * Write a single line of input, including the newline at the end. * @param line the line */ void writeLine( String line ) throws IOException; } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootplexus-interactivity-api/src/main/java/org/codehaus/plexus/components/interactivity/DefaultOutputHandler.javaplexus-interactivity-api/src/main/java/org/codehaus/plexus/components/interactivity/DefaultOutputHan0000644000175000017500000000431410322514664033332 0ustar paulpaulpackage org.codehaus.plexus.components.interactivity; /* * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ import org.codehaus.plexus.personality.plexus.lifecycle.phase.Disposable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; import java.io.IOException; import java.io.PrintWriter; /** * Default output handler, that uses the console. * * @author Brett Porter * @version $Id: DefaultOutputHandler.java 2648 2005-10-10 16:41:24Z brett $ */ public class DefaultOutputHandler implements Initializable, Disposable, OutputHandler { private PrintWriter consoleWriter; public void initialize() throws InitializationException { consoleWriter = new PrintWriter( System.out ); } public void dispose() { consoleWriter.close(); } public void write( String line ) throws IOException { consoleWriter.print( line ); consoleWriter.flush(); } public void writeLine( String line ) throws IOException { consoleWriter.println(); } } plexus-interactivity-api/src/main/java/org/codehaus/plexus/components/interactivity/Prompter.java0000644000175000017500000000370210322516047032623 0ustar paulpaulpackage org.codehaus.plexus.components.interactivity; /* * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ import java.util.List; /** * Prompt the user for input. * * @author Brett Porter * @version $Id: Prompter.java 2649 2005-10-10 16:51:51Z brett $ */ public interface Prompter { String ROLE = Prompter.class.getName(); String prompt( String message ) throws PrompterException; String prompt( String message, String defaultReply ) throws PrompterException; String prompt( String message, List possibleValues ) throws PrompterException; String prompt( String message, List possibleValues, String defaultReply ) throws PrompterException; String promptForPassword( String message ) throws PrompterException; void showMessage( String message ) throws PrompterException; } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootplexus-interactivity-api/src/main/java/org/codehaus/plexus/components/interactivity/DefaultInputHandler.javaplexus-interactivity-api/src/main/java/org/codehaus/plexus/components/interactivity/DefaultInputHand0000755000175000017500000000475710322516047033310 0ustar paulpaulpackage org.codehaus.plexus.components.interactivity; /* * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Disposable; import org.codehaus.plexus.components.interactivity.AbstractInputHandler; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** * Default input handler, that uses the console. * * @author Brett Porter * @version $Id: DefaultInputHandler.java 2649 2005-10-10 16:51:51Z brett $ */ public class DefaultInputHandler extends AbstractInputHandler implements Initializable, Disposable { private BufferedReader consoleReader; public String readLine() throws IOException { return consoleReader.readLine(); } public String readPassword() throws IOException { return consoleReader.readLine(); } public void initialize() throws InitializationException { consoleReader = new BufferedReader( new InputStreamReader( System.in ) ); } public void dispose() { try { consoleReader.close(); } catch ( IOException e ) { getLogger().error( "Error closing input stream must be ignored", e ); } } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootplexus-interactivity-api/src/main/java/org/codehaus/plexus/components/interactivity/DefaultPrompter.javaplexus-interactivity-api/src/main/java/org/codehaus/plexus/components/interactivity/DefaultPrompter.0000644000175000017500000001401310322516047033263 0ustar paulpaulpackage org.codehaus.plexus.components.interactivity; /* * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ import org.codehaus.plexus.util.StringUtils; import java.io.IOException; import java.util.Iterator; import java.util.List; /** * Default prompter. * * @author Brett Porter * @version $Id: DefaultPrompter.java 2649 2005-10-10 16:51:51Z brett $ */ public class DefaultPrompter implements Prompter { /** * @requirement */ private OutputHandler outputHandler; /** * @requirement */ private InputHandler inputHandler; public String prompt( String message ) throws PrompterException { try { writePrompt( message ); } catch ( IOException e ) { throw new PrompterException( "Failed to present prompt", e ); } try { return inputHandler.readLine(); } catch ( IOException e ) { throw new PrompterException( "Failed to read user response", e ); } } public String prompt( String message, String defaultReply ) throws PrompterException { try { writePrompt( formatMessage( message, null, defaultReply ) ); } catch ( IOException e ) { throw new PrompterException( "Failed to present prompt", e ); } try { String line = inputHandler.readLine(); if ( StringUtils.isEmpty( line ) ) { line = defaultReply; } return line; } catch ( IOException e ) { throw new PrompterException( "Failed to read user response", e ); } } public String prompt( String message, List possibleValues, String defaultReply ) throws PrompterException { String formattedMessage = formatMessage( message, possibleValues, defaultReply ); String line; do { try { writePrompt( formattedMessage ); } catch ( IOException e ) { throw new PrompterException( "Failed to present prompt", e ); } try { line = inputHandler.readLine(); } catch ( IOException e ) { throw new PrompterException( "Failed to read user response", e ); } if ( StringUtils.isEmpty( line ) ) { line = defaultReply; } if ( line != null && !possibleValues.contains( line ) ) { try { outputHandler.writeLine( "Invalid selection." ); } catch ( IOException e ) { throw new PrompterException( "Failed to present feedback", e ); } } } while ( line == null || !possibleValues.contains( line ) ); return line; } public String prompt( String message, List possibleValues ) throws PrompterException { return prompt( message, possibleValues, null ); } public String promptForPassword( String message ) throws PrompterException { try { writePrompt( message ); } catch ( IOException e ) { throw new PrompterException( "Failed to present prompt", e ); } try { return inputHandler.readPassword(); } catch ( IOException e ) { throw new PrompterException( "Failed to read user response", e ); } } private String formatMessage( String message, List possibleValues, String defaultReply ) { StringBuffer formatted = new StringBuffer( message.length() * 2 ); formatted.append( message ); if ( possibleValues != null && !possibleValues.isEmpty() ) { formatted.append( " (" ); for ( Iterator it = possibleValues.iterator(); it.hasNext(); ) { String possibleValue = (String) it.next(); formatted.append( possibleValue ); if ( it.hasNext() ) { formatted.append( '/' ); } } formatted.append( ')' ); } if ( defaultReply != null ) { formatted.append( ' ' ).append( defaultReply ).append( ": " ); } return formatted.toString(); } private void writePrompt( String message ) throws IOException { outputHandler.write( message + ": " ); } public void showMessage( String message ) throws PrompterException { try { writePrompt( message ); } catch ( IOException e ) { throw new PrompterException( "Failed to present prompt", e ); } } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootplexus-interactivity-api/src/main/java/org/codehaus/plexus/components/interactivity/AbstractInputHandler.javaplexus-interactivity-api/src/main/java/org/codehaus/plexus/components/interactivity/AbstractInputHan0000755000175000017500000000361110322516047033307 0ustar paulpaulpackage org.codehaus.plexus.components.interactivity; /* * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ import org.codehaus.plexus.logging.AbstractLogEnabled; import java.util.List; import java.util.ArrayList; import java.io.IOException; /** * Base input handler, implements a default readMultipleLines. * * @author Brett Porter * @version $Id: AbstractInputHandler.java 2649 2005-10-10 16:51:51Z brett $ */ public abstract class AbstractInputHandler extends AbstractLogEnabled implements InputHandler { public List readMultipleLines() throws IOException { List lines = new ArrayList(); String line = readLine(); while ( line != null && line.length() > 0 ) { lines.add( line ); line = readLine(); } return lines; } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootplexus-interactivity-api/src/main/java/org/codehaus/plexus/components/interactivity/InputHandler.javaplexus-interactivity-api/src/main/java/org/codehaus/plexus/components/interactivity/InputHandler.jav0000755000175000017500000000452710322516047033260 0ustar paulpaulpackage org.codehaus.plexus.components.interactivity; /* * The MIT License * * Copyright (c) 2005, The Codehaus * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ import java.util.List; import java.io.IOException; /** * 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 Brett Porter * @version $Id: InputHandler.java 2649 2005-10-10 16:51:51Z brett $ */ public interface InputHandler { String ROLE = InputHandler.class.getName(); /** * Read a single line of input, swalling the newline at the end. * If the input can be echoed, it will be. * @return the line read */ String readLine() throws IOException; /** * Read a single line of input, swalling the newline at the end. * This method guarantees input is not echoed. * @return the line read */ String readPassword() throws IOException; /** * Read a set of lines. Equivalent to multiple calls to {@link #readLine()}. * Ends when an empty line is encountered. * @return a list of lines read */ List readMultipleLines() throws IOException; }