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

InvalidArgumentName when argument name has trailing digit #62

Open
srki-lendup opened this issue Aug 15, 2018 · 2 comments
Open

InvalidArgumentName when argument name has trailing digit #62

srki-lendup opened this issue Aug 15, 2018 · 2 comments

Comments

@srki-lendup
Copy link

srki-lendup commented Aug 15, 2018

val url1 by parser.storing(help = "jdbc url. Example: jdbc:postgresql://localhost:5432/db1")

results in:

Exception in thread "main" java.lang.IllegalArgumentException: URL1 is not a valid argument name

Not sure if this is by design or a bug. Changing to the following fixes the issue:

val url_1 by parser.storing(help = "jdbc url. Example: jdbc:postgresql://localhost:5432/db1")

@bzdzb
Copy link

bzdzb commented Oct 23, 2018

I started to fix this bug, but after looking at the tests realized that this was intentional behavior. I encountered this issue when trying to implement a parser.stored() call with the arg --s3-bucket. Since this is a perfectly reasonable arg name, I think this design decision might warrant reconsideration. I'd be happy to submit a pull request if you agree that it makes sense. Thanks.

@xenomachina
Copy link
Owner

@bzdzb from looking at where ARG_NAME_RE is defined, I suspect that this was not actually intentional. Instead of $ARG_INITIAL_CHAR_CLASS+, $ARG_INITIAL_CHAR_CLASS$ARG_CHAR_CLASS* would probably make more sense.

I'm also thinking that it may make sense to require $ARG_INITIAL_CHAR_CLASS after a ..

So these should be valid:

url1
url_1
url-1
http_url1
http_url_1
http_url-1
http-url1
http-url_1
http-url-1
http.url1
http.url_1
http.url-1
http_url_1_host
http_url_1-host
http_url-1_host
http_url-1-host
http_url1_host
http_url1-host
http-url_1_host
http-url_1-host
http-url-1_host
http-url-1-host
http-url1_host
http-url1-host
http.url_1_host
http.url_1-host
http.url-1_host
http.url-1-host
http.url1_host
http.url1-host

but these should be invalid:

3com
3_com
3-com
3.com
http_url.1
http-url.1
http.url.1
http_url.1_host
http_url.1-host
http-url.1_host
http-url.1-host
http.url.1_host
http.url.1-host
-url
_url
url_
url-
.url
url.

If you'd be willing to make a PR, I'd really appreciate it.

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

No branches or pull requests

3 participants