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

WIP: Parse endpoints using argparse #76

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jayvdb
Copy link
Contributor

@jayvdb jayvdb commented Jul 15, 2022

No description provided.

@jayvdb
Copy link
Contributor Author

jayvdb commented Jul 15, 2022

Happy to re-add find_endpoint and mark it as deprecated somehow.
Also happy to add more tests to help guarantee this is working correctly for any edge cases.

@cmhulbert
Copy link
Contributor

This is really coincidental; I've run into this issue also the last few days, and just last night (shortly before this issue), I opened a PR to fix this as well #74

I take a different approach though, just adding a patter to match window's drive letters and ignore, similar to how it already did for http://


args, unknown = parser.parse_known_args(argv[:endpoint_index])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've found a regression caused by this. If the program args contains hyphenated args, e.g. ["com.pinterest:ktlint", "-F", "/c/path/to/file.kt"] , the hyphenated arg becomes a JVM arg.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A workaround for this is for people to use -- , i.e. ["com.pinterest:ktlint", "--", "-F", "/c/path/to/file.kt"]
Requiring that workaround would mean this is a breaking change.
Looking for other solutions ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using -- isnt enough.
["--add-opens", "java.base/java.lang=ALL-UNNAMED", "com.pinterest:ktlint", "--", "-F", "/c/path/to/file.kt"] ends up with jvm arg ["--add-opens"] and endpoint java.base/java.lang=ALL-UNNAMED. :-(

@ctrueden ctrueden self-assigned this Jul 25, 2022
@ctrueden
Copy link
Member

@jayvdb Do you think the merge of #74 is sufficient to address your needs here? I.e. can this PR be closed? Or are there still benefits to updating and merging it?

@jayvdb
Copy link
Contributor Author

jayvdb commented Jul 31, 2022

I think there are benefits in where I was going with this, but I want to first get tests in place for the current behaviour, before attempting to take this approach further. I'll get a WIP up shortly.

additional endpoints and shortcuts fail
@jayvdb jayvdb changed the title Fix parsing of endpoint Parse endpoints using argparse Aug 1, 2022
@jayvdb jayvdb changed the title Parse endpoints using argparse WIP: Parse endpoints using argparse Aug 1, 2022
@jayvdb
Copy link
Contributor Author

jayvdb commented Aug 1, 2022

@ctrueden, I am pretty confident that I can get this working correctly, resulting in no more attempt to parse the program_args and all the problems that can cause. OTOH, complexity goes through the roof, and we'd be using 'private' parts of the ArgumentParser class (_match_arguments_partial and _parse_optional), and making parse_args stateful (with those new members of the ArgumentParser) which is contrary to its intent.

Should I keep going?

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 this pull request may close these issues.

3 participants