Skip to content

scanAndBind appears to be failing to find any flags #5

@malachid

Description

@malachid

Test class:

public class FlagTest
{
    @FlagInfo(name="debug", altName="d", help="Enable debug logging")
    private static final Flag<Boolean> debug = Flagz.valueOf(false);

    public static void main(String ... args)
    {
        Arrays.stream(args).forEach(arg -> System.out.format("ARG FOUND: %s\n", arg));

        FlagFieldRegistry registry = Flagz.parse(args);
        if(debug.get()) {
            System.out.format("Debug logging enabled...\n");
        }
    }
}

Whether I make the debug field private or public, when attempting to run this snippet I get the following error (against 2.1.0):

ARG FOUND: --debug
Exception in thread "main" org.flagz.FlagException$UnknownFlag: Could not find Flag for name/alt-name 'debug'
        at org.flagz.FlagFieldRegistry.parseAll(FlagFieldRegistry.java:56)
        at org.flagz.Flagz.parse(Flagz.java:101)
        at org.flagz.Flagz.parse(Flagz.java:112)
        at org.eoti.sandbox2.flagz.FlagTest.main(FlagTest.java:22)

I have tried with both JDK8 and Jigsaw JDK9.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions