Interactive parameter asks for value to be entered at once
See original GitHub issueI have the following Main class with subcommands:
@Command(description = "MyTools for testing",
name = "MyTools",
mixinStandardHelpOptions = true,
usageHelpWidth = 120,
version = "MyTools 1.0",
subcommands = {
//some other commands
BCryptPasswordCommand.class
}
)
public class Main implements Callable<Void> {
@CommandLine.Option(names = {"--verbose"}, description = "to produce more information, especially for error debugging", defaultValue = "false")
private boolean verbose;
@Override
public Void call() {
System.err.println("Missing a sub-command specification");
new CommandLine(new Main()).usage(System.err);
System.exit(1);
return null;
}
public static void main(String[] args) {
Main main = new Main();
try {
//CommandLine.call(main, args);
new CommandLine(main).execute(args);
} catch (Exception e) {
// print exception
}
}
}
and the BCryptPasswordCommand
:
@CommandLine.Command(
description = "BCrypt the password",
name = "encodePwd")
public class BCryptPasswordCommand implements Callable<Void> {
@CommandLine.Parameters(index = "0", interactive = true, description = "Password to encrypt")
private String password;
@Override
public Void call() throws Exception {
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
String encodedPassword = encoder.encode(password);
CliUtil.printCliInfoMessage(encodedPassword);
return null;
}
}
WHAT I DO:
i run java -jar myTools.jar encodePwd
CURRENT BEHAVIOR:
i’m not offered to enter password, the code just runs with null password.
EXPECTED:
i’m offered to enter password
It’s interesting that when i do java -jar myTools.jar encodePwd blabla
, i’m offered to enter the password interactively, but then get: Unmatched argument at index 1: 'blabla'
, so it looks like it takes both arguments into account: “blabla” and the one entered interectively after.
VERSION: the same for 3.9.5 and 4.0.4
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Use parameters to ask for input when running a query
To make a query in Access desktop databases ask for criteria when you run it, create a parameter query. This allows you to...
Read more >Use Parameters to Make Views More Interactive - Tableau Help
For Allowable Values, select List, type None as the first value in the list, and then press Enter. Complete the list by typing...
Read more >Parameters | Query and analyze data - Mode Support
Use parameters to make reports more scalable, re-usable and interactive by allowing viewers to modify the data returned by a report without modifying...
Read more >Run an R Markdown based on interactive parameter choice
Let there be a file called foo.Rmd with this content: --- title: "SUM and SAM" output: html_document params: machine: input: select choices: ...
Read more >Pipeline: Input Step - Jenkins
If just one parameter is listed, its value will become the value of the input step. If multiple parameters are listed, the return...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If you like picocli, please star the project on GitHub and tell your friends. 😃
I added a cautionary note to the user manual: https://picocli.info/#_interactive_password_options