azimjohn / jprq

join public router. quickly.
https://jprq.io
972 stars 146 forks source link

Fix cli flags order #149

Closed mmkamron closed 1 year ago

mmkamron commented 1 year ago

Fixes #148

After recent changes, there is a little confusion in the flags order. If a user has a flag -s for the subdomain feature, it doesn't work. However, it works when there is also a --debug option in the last parameter. This PR will temporarily fix that issue. I'd suggest using Go's flag package as more options may appear in the future.

azimjohn commented 1 year ago

Thanks Kamron, indeed parsing flags are getting out of hand.

The problem is there're 3 types of args {"subcommand", "-key value", "--flag"}.

Standard flag package doesn't have definitions for all these types and may require passing protocol as "--protocol or -p" and it's not good.

Post a PR if you think it's possible to do it cleaner way.

mmkamron commented 1 year ago

There is a NewFlagSet function in the flag package, maybe that's what we need to use in this case. Because current if-else trick worries me. Here is a basic overview. By the way, I admire you implementing many functions yourself thus minimizing the dependencies and libraries.