-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#802] add echo and prompt for interactive option
- Loading branch information
1 parent
a610c7c
commit d767f5d
Showing
3 changed files
with
417 additions
and
40 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
picocli-examples/src/main/java/picocli/examples/interactive/UserPasswordDemo.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,34 @@ | ||
package picocli.examples.interactive; | ||
|
||
import picocli.CommandLine; | ||
import picocli.CommandLine.Parameters; | ||
|
||
public class UserPasswordDemo implements Runnable { | ||
|
||
@Parameters(index = "0", description = {"User"}, interactive = true, echo = true, prompt = "Enter your user: ") | ||
String user; | ||
|
||
@Parameters(index = "1", description = {"Password"}, interactive = true, prompt = "Enter your password: ") | ||
String password; | ||
|
||
@Parameters(index = "2", description = {"Action"}) | ||
String action; | ||
|
||
public void run() { | ||
// See also PasswordDemo | ||
login(user, password); | ||
doAction(action); | ||
} | ||
|
||
private void login(String user, String pwd) { | ||
System.out.printf("User: %s, Password: %s%n", user, pwd); | ||
} | ||
|
||
private void doAction(String action) { | ||
System.out.printf("Action: %s%n", action); | ||
} | ||
|
||
public static void main(String[] args) { | ||
new CommandLine(new UserPasswordDemo()).execute(args); | ||
} | ||
} |
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.