+
Skip to content

FlagProp flag behavior should only apply to command line Loader #656

@eeverman

Description

@eeverman

Currently any reference to a FlagProp causes it to be set to true, e.g. this snippet in a properties file will set CREATE_SAMPLES to true:

org.yarnandtail.andhow.Options.CREATE_SAMPLES =

For most users, this would be unexpected and unwanted.

This causes issue #655 resulting unwanted requests for template creation... from using generated templates.
Its helpful to have a configuration template that is blank and ready to fill in, but in order to fix #655, FlagProp's have to be commented out.

It seems that Flag behavior is dependent on the loader being used (command-line loader) and the ValueType (it has to be a flag). Perhaps there is an undiscovered loader type for which the current flag behavior would also make sense, but I can't think of it.

Describe the solution you'd like
A FlagProp should behave like a BolProp with a default value, everywhere except when used on command line. To do that:

  • Add FlagValueType interface with a parseAsFlag(sourceValue) method and implement in FlagType
  • The StdMainStringArgsLoader (and maybe its superclasses?) should override the createValue method to call the new parseAsFlag method for FlagValueTypes.

See #699 for reverting an original hack related to this issue.

Related: It seems like the createValue method should 'trust' the ValueType parsers more. On line 199 it assumes that the parsers cannot deal with null, but maybe they can and want to do something special with null.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载