Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support echo and prompt for an interactive option #1284

Merged
merged 1 commit into from
Dec 14, 2020

Conversation

sakata1222
Copy link
Contributor

PR for #802.

  • If echo is true, just uses BufferedReader#readLine not Console#readPassword to read user input.
  • If prompt is not empty, the specified string will be displayed to the end user for an interactive option.
  • The default values:
    • echo : false
    • prompt : empty string

Here is the result of a sample class added by this PR. I use Windows 10.

PS C:\xxxxx\picocli> java -version
openjdk version "11.0.9.1" 2020-11-04
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9.1+1)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.9.1+1, mixed mode)

PS C:\xxxxx\picocli> java -cp "build/libs/picocli-4.5.3-SNAPSHOT.jar;picocli-examples/build/libs/picocli-examples.jar" picocli.examples.interactive.UserPasswordDemo "sample action"
Enter your user: dummy
Enter your password:
User: dummy, Password: secret
Action: sample action

@codecov-io
Copy link

codecov-io commented Dec 13, 2020

Codecov Report

Merging #1284 (d767f5d) into master (a610c7c) will increase coverage by 0.01%.
The diff coverage is 85.45%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1284      +/-   ##
============================================
+ Coverage     93.82%   93.83%   +0.01%     
  Complexity      462      462              
============================================
  Files             2        2              
  Lines          6852     6882      +30     
  Branches       1842     1848       +6     
============================================
+ Hits           6429     6458      +29     
- Misses          138      141       +3     
+ Partials        285      283       -2     
Impacted Files Coverage Δ Complexity Δ
src/main/java/picocli/CommandLine.java 93.66% <85.45%> (+0.01%) 318.00 <0.00> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a610c7c...d767f5d. Read the comment docs.

@remkop remkop merged commit 74e41cd into remkop:master Dec 14, 2020
@remkop remkop added this to the 4.6 milestone Dec 14, 2020
@remkop remkop linked an issue Dec 14, 2020 that may be closed by this pull request
@remkop
Copy link
Owner

remkop commented Dec 14, 2020

Merged.
Thank you for the contribution! This will be included in the 4.6 release.
(I still need to update the release notes.)

remkop added a commit that referenced this pull request Dec 15, 2020
MarkoMackic pushed a commit to MarkoMackic/picocli that referenced this pull request Oct 17, 2021
MarkoMackic pushed a commit to MarkoMackic/picocli that referenced this pull request Oct 17, 2021
MarkoMackic pushed a commit to MarkoMackic/picocli that referenced this pull request Oct 17, 2021
MarkoMackic added a commit to MarkoMackic/picocli that referenced this pull request Oct 17, 2021
MarkoMackic added a commit to MarkoMackic/picocli that referenced this pull request Oct 17, 2021
MarkoMackic added a commit to MarkoMackic/picocli that referenced this pull request Oct 17, 2021
MarkoMackic added a commit to MarkoMackic/picocli that referenced this pull request Oct 17, 2021
MarkoMackic added a commit to MarkoMackic/picocli that referenced this pull request Oct 17, 2021
MarkoMackic added a commit to MarkoMackic/picocli that referenced this pull request Oct 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow interactive options that echo to the console
3 participants