Picocli: How can one handle no arguments and options scenario

Arsene :

I am using the picocli java command line library to implement a command line application. However I would like to know whether picocli offers a feature that can help handle the situation where the command line does not receive any arguments or options something default case.

Thank you

Remko Popma :

I'm not sure if this answers your question, but it is certainly possible to create a picocli-based command that has no options or positional parameters:

@Command(name = "demo", description = "no options or positional parameters")
public class Demo implements Runnable {

    @Override
    void run() {
        System.out.println("Hello");
    }

    public static void main(String[] args) {
        CommandLine.run(new Demo(), args);
    }
}

Or is your question about how options can be given default values? If that is the case, can you take a look at the Default Values section of the user manual and let us know what is unclear?

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=105549&siteId=1