question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Interactive parameter asks for value to be entered at once

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
remkopcommented, Oct 21, 2019

If you like picocli, please star the project on GitHub and tell your friends. 😃

1reaction
remkopcommented, Oct 20, 2019

I added a cautionary note to the user manual: https://picocli.info/#_interactive_password_options

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found