Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Envars ignored in mutuallyExclusiveOptions #384

Closed
amkad opened this issue Dec 26, 2022 · 0 comments · Fixed by #385
Closed

Envars ignored in mutuallyExclusiveOptions #384

amkad opened this issue Dec 26, 2022 · 0 comments · Fixed by #385

Comments

@amkad
Copy link

amkad commented Dec 26, 2022

It looks like envvars in mutuallyExclusiveOptions do not work in 3.5.0

class SomeTool: NoOpCliktCommand() {
    val password by mutuallyExclusiveOptions(
        option("--password-file", envvar = "PASSWORD_FILE").file().convert { it.readText() },
        option("--password", envvar = "PASSWORD"),
    )
}

class Issue {
    @Test
    fun mutuallyExclusiveOptionsWithEnvVars() {
        val envvars = mapOf("PASSWORD" to "secret")
        val tool = SomeTool().context {
            envvarReader = { envvars[it] }
        }
        tool.parse(emptyList())
        assertEquals("secret", tool.password)
    }
}
org.opentest4j.AssertionFailedError: 
Expected :secret
Actual   :null

It works fine with 3.4.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant