-
Notifications
You must be signed in to change notification settings - Fork 500
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
convert to getopt_long for option parsing #871
Comments
This is one of the most valuable work items as a first step to support Android. |
I want to contribute this issue! |
Great! Please go ahead. |
@binkoni can I take this over? |
@namhyung
Sure you can :)
2020년 3월 29일 (일) 오후 4:37, Namhyung Kim <[email protected]>님이 작성:
… @binkoni <https://github.com/binkoni> can I take this over?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#871 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABQNFIHOTNZU53INMPTNULDRJ33ERANCNFSM4IW2O5OQ>
.
|
The argp_parse() has portability issues as some systems miss the implementation by default. So convert it to getopt_long() for better compatibility. It needs more manual work when you add a new option, but it'd be more flexible to handle help messages at least. The notable change is that it now requires subcommand name as the first argument. This is somewhat annoying for me but I don't know how I can fix it with getopt(). So the following example will not work anymore (sadly). $ ./uftrace -L . record tests/t-abc It should be like below: $ ./uftrace record -L . tests/t-abc Closed: #871 Signed-off-by: Namhyung Kim <[email protected]>
Pushed review/getopt-v1. |
Thanks a lot for the update. It mostly works fine, but it doesn't properly pass target options.
It requires explicit
|
The simpler example is as follows.
The following
|
Thanks for testing. I don't know how I can control that.. |
Oh, I found that we can control non-option behavior using the short option string prefix ("+"). Please check review/getopt-v2. from the man page of getopt_long(3):
|
I tested and confirmed that it works fine now. Thanks a lot for your work! |
Thanks for the testing! |
Currently it uses
argp_parse()
to parse command line options. But it's glibc-specific so has some portability problems. While there's a supporting library for this, it'd be nice to avoid using it. I think it's rather straight-forward to convert the option parser to usegetopt_long()
instead.The text was updated successfully, but these errors were encountered: