Skip to content

Picocli should disallow split regex for single-value type options (was: Argument groups: false error message when using split regex) #745

@deining

Description

@deining

I'm running the minimum working example below:

package test;

import picocli.CommandLine;
import picocli.CommandLine.ArgGroup;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;

public class ArgGroupsTest {

    public static void main(String[] args) {
        CommandLine cmd = new CommandLine(new TestCommand());
        cmd.execute( "-option=1,2");
    }

    @Command(name = "ArgGroupsTest")
    static class TestCommand implements Runnable {

        @ArgGroup( exclusive = false)
        DataSource datasource;

        static class DataSource {
            @Option(names = "-option", split = "," )
            int value;
        }

        @Override
        public void run() {
            // nothing to do here
        }
    }
}

IMHO, the program should exit gracefully, however, an error message is thrown:

Invalid value for option '-option': '1,2' is not an int
Usage: ArgGroupsTest [[-option=<value>[,<value>...]]]
      -option=<value>[,<value>...]

Is this the intended behaviour?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions