Closed sergei-mironov closed 3 years ago
I can try this @grwlf
@sonuishaq67 OK, then take it. Feel free to post questions here.
I have added few words to the description
Im using getopt3
and i have a doubt even though I specified
no_argument
in optionsit asks for argument in small option
ex : ./xkb-switch --version works
but
./xkb-switch -v
doesnt work butgives an error of ./xkb-switch: option requires an argument -- 'v'
nvm I figured it out./xkb-switch -v.
works
How to check which test is failing ? @grwlf
Figured it out
All test are passing now
Ill send a pr
@sonuishaq67 Thank you for help!
Hi @sonuishaq67 ! I just found an issue in your implementation. Currently xkb-switch
doesn't accept --arg=value
format for set. So, ./xkb-switch --set=us
doesn't work. But getopts
's manpage says that it does support this format. This is likely because you read argument of -s
from argv[i++]
explicitly, while the correct way should be to use getopt-API. I think one should try reading the values from optarg
.
Could you please correct this?
Okay sure I'll try to correct it
Hey @grwlf A few functions are not required because getopt already covers them Should I remove those ?
Edit : For now I didn't remove those
Hey @grwlf A few functions are not required because getopt already covers them Should I remove those ?
Edit : For now I didn't remove those
Yep, I would prefer not to use temp variable, but the change is trivial so I removed it already and also made a few small adjustments. Thank you!
We need replace homegrown command-line arguments parser with
getopt
or alike. The goal is to makexkb-switch
CLI handling more standard. For example, now it doesn't process 'tightly coupled' one-letter flags, like-ld
instead of-l -d
. Getopt family of functions could do it.Contributions are welcome here.
XKbSwitch.cpp
getopt
family of C functionsCMakeLists.txt
if required./test.sh
still prints OKPlease, do not introduce non-standard dependencies like boost. Use stdlib C or C++ < 11 tools.