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

Arguments with equals are incorrectly interpreted as options #106

Closed
eschrock opened this issue Dec 15, 2019 · 1 comment · Fixed by #107
Closed

Arguments with equals are incorrectly interpreted as options #106

eschrock opened this issue Dec 15, 2019 · 1 comment · Fixed by #107

Comments

@eschrock
Copy link

We are trying to use clikt for a command that can take a URL as an argument. This can have query parameters, but it seems like any argument with a "=" in the name is treated as an argument. For example:

class Hello : CliktCommand() {
    val arg by argument()
    override fun run() {
        echo("Argument: $arg")
    }
}

fun main(args: Array<String>) = Hello().main(args)
$ hello foo
Argument: foo
$ hello foo=bar
Error: no such option: "foo".

The docs state:

Clikt normally parses any value that starts with punctuation as an option, which allows users to intermix options and arguments. However, sometimes you need to pass a value that starts with punctuation to an argument. For example, you might have a file named -file.txt that you want to use as an argument.

However, in this case, we do not have any starting punctuation, so I don't know why it's trying to parse it as an option.

While we can ask users to use the "--" delimeter, it means that it will effectively always need to be used. This is a pretty annoying experience.

I've never seen a command that behaves this way, so I'm assuming this is a bug. If this is indeed the desired behavior, could a mechanism be provided to disable it?

@ajalt
Copy link
Owner

ajalt commented Dec 17, 2019

That's definitely a bug. Thanks for the well written report!

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.

2 participants