Skip to content

Add support for custom interpolation lookup strategies #1777

@ahrytsiuk

Description

@ahrytsiuk

As a developer, I want to add custom interpolation lookup strategies for option default value.

Currently, interpolation strategies are hardcoded in the picocli.CommandLine.Model.Interpolator class. And have the following options:

  • sys:
  • env:
  • bundle:

It would be nice if I can add/register my own strategy. For example when developing Spring Boot application - I want to be able to use the standard Spring Boot configuration mechanism to populate option values.

Let's imagine the following code sample:

       @CommandLine.Option(
            names = "--server-url",
            required = true,
            description = "Server base path URL",
            defaultValue = "{spring-env:server.base-url}"
        )
        public void setBaseUrl(String baseUrl) {
            this.baseUrl = baseUrl;
        }

I expect the default value for this option to be populated from the Spring Boot Environment, if it wasn't specified in the CLI arguments.

And of course, I have to provide the implementation for such a strategy by myself.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions