Skip to content

IDefaultValueProvider for Map options with multiple values without using split regexp #2362

@usmansaleem

Description

@usmansaleem

I have following declaration for key/value pairs to be captured:

  @Option(
      names = "--aws-kms-tag,
      mapFallbackValue = "",
      description =
          "Optional key-value pair to filter KMS keys based on tags. Format: --aws-kms-tag <tag-name>=<tag-value>. Can be repeated.",
      paramLabel = "<TAG_NAME>=<TAG_VALUE>")
  private Map<String, String> tags = new LinkedHashMap<>();

I can specify it on command line as follows and it works fine:

java myApp --aws-kms-tag tagNameA=tagValueA --aws-kms-tag tagNameB=tagValueB

However, my application is also using IDefaultValueProvider to capture values from configuration file and environment variables. The defaultValue method returns a String.

    public interface IDefaultValueProvider {
        String defaultValue(Model.ArgSpec var1) throws Exception;
    }

If the option is not using a split RegExp, how can I assign multiple key=value pairs for defaultValue?

i.e. yaml configuration file would look like:

aws-kms-tag:
  tagNameA: tagValueA
  tagNameB: tagValueB

If above is not possible, I think I have to introduce split regexp approach that I use with Collection classes with setting arity to 0..1.

Reference of current Yaml based default provider:

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions