Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Former-commit-id: eefe77ce270ffe0919f2e18f1526e38544d8667d
- Loading branch information
Showing
13 changed files
with
191 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package ch.cyberduck.cli; | ||
|
||
/* | ||
* Copyright (c) 2002-2015 David Kocher. All rights reserved. | ||
* http://cyberduck.ch/ | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* Bug fixes, suggestions and comments should be sent to feedback@cyberduck.ch | ||
*/ | ||
|
||
/** | ||
* @version $Id$ | ||
*/ | ||
class DisabledTerminalPromptReader implements TerminalPromptReader { | ||
@Override | ||
public boolean prompt(final String message) { | ||
return true; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
source/ch/cyberduck/cli/InteractiveTerminalPromptReader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package ch.cyberduck.cli; | ||
|
||
/* | ||
* Copyright (c) 2002-2015 David Kocher. All rights reserved. | ||
* http://cyberduck.io/ | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* Bug fixes, suggestions and comments should be sent to: | ||
* feedback@cyberduck.io | ||
*/ | ||
|
||
import ch.cyberduck.core.exception.ConnectionCanceledException; | ||
|
||
/** | ||
* @version $Id$ | ||
*/ | ||
public class InteractiveTerminalPromptReader implements TerminalPromptReader { | ||
|
||
private final Console console = new Console(); | ||
|
||
@Override | ||
public boolean prompt(final String message) { | ||
final String input; | ||
try { | ||
input = console.readLine("%n%s (y/n): ", message); | ||
} | ||
catch(ConnectionCanceledException e) { | ||
return false; | ||
} | ||
switch(input) { | ||
case "y": | ||
return true; | ||
case "n": | ||
return false; | ||
default: | ||
console.printf("Please type 'y' or 'n'."); | ||
return this.prompt(message); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.