这是indexloc提供的服务,不要输入任何密码
Skip to content

Problem with ScopeType.INHERIT #2436

@MagnusMG

Description

@MagnusMG

I get a weird error message when I run my program:

Exception in thread "main" picocli.CommandLine$DuplicateOptionAnnotationsException: Option name '-l' is used by both field int se.magnusgunnarsson.kutil.Reportable.opt_level and field int se.magnusgunnarsson.kutil.Reportable.opt_level
        at picocli.CommandLine$DuplicateOptionAnnotationsException.create(CommandLine.java:18739)
        at picocli.CommandLine$DuplicateOptionAnnotationsException.access$2900(CommandLine.java:18733)
        at picocli.CommandLine$Model$CommandSpec.addOption(CommandLine.java:6790)
        at picocli.CommandLine$Model$CommandSpec.add(CommandLine.java:6774)
        at picocli.CommandLine$Model$CommandSpec.addSubcommand(CommandLine.java:6605)
        at picocli.CommandLine$Model$CommandReflection.initSubcommands(CommandLine.java:11908)
        at picocli.CommandLine$Model$CommandReflection.extractCommandSpec(CommandLine.java:11873)
        at picocli.CommandLine$Model$CommandSpec.forAnnotatedObject(CommandLine.java:6396)
        at picocli.CommandLine.<init>(CommandLine.java:230)
        at picocli.CommandLine.<init>(CommandLine.java:224)
        at picocli.CommandLine.<init>(CommandLine.java:199)
        at se.magnusgunnarsson.rankings.UniRankKt.main(UniRank.kt:72)

se.magnusgunnarsson.kutil.Reportable is an abstract base class that the current main class inherits from. Reportable defines the option -l, but it is not defined anywhere else. The option -l is defined with scope = ScopeType.INHERIT. If I remove that everything works fine.

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