-
Notifications
You must be signed in to change notification settings - Fork 2
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
[FEATURE REQUEST] - getopts - parse cli arguments #9
Comments
Imagine using default options and omitting them. as in HiddenServiceVersion, the only available |
Implementiong bare hands because posix getopts is horrible for only short options and getoptions is out of my league. while true; do
case "${1}" in
on|off|list|renew|web|location|backup|restore|vanguards) command="${1}"; shift;;
auth-server|auth-client) command="${1%-*}"; host="${1#*-}"; : "${host:?$(error_msg "host is missing")}"; shift;;
--install|--logs|--upgrade|--remove|--nginx|--apache|--html|--create|--integrate) action="${1}"; shift;;
--on|--off|--list) status="${1}"; shift;;
-s|--service) service="${2:?$(error_msg "service is missing")}"; shift 2;;
--service=*) service="${1#*=}"; : "${service:?$(error_msg "service is missing")}"; shift;;
-c|--client) client="${2:?$(error_msg "client is missing")}"; shift 2;;
--client=*) client="${1#*=}"; : "${client:?$(error_msg "client is missing")}"; shift;;
-o|--onion) onion="${2:?$(error_msg "onion is missing")}"; shift 2;;
--onion=*) onion="${1#*-}"; : "${onion:?$(error_msg "onion is missing")}"; shift;;
-P|--purge) purge="${1}"; shift;;
-v|--version) version="${2:?$(error_msg "version is missing")}"; shift 2;;
--version=*) version="${1#*=}"; : "${version:=3}"; shift;;
-S|--socket) socket="${2:?$(error_msg "socket is missing")}"; shift 2;;
--socket=*) socket="${1#*=}"; : "${socket:?$(error_msg "socket is missing")}"; shift;;
-p|--port) port="${2:?$(error_msg "port is missing")}"; shift 2;;
--port=*) port="${1#*=}"; : "${ports:?$(error_msg "port is missing")}"; shift;;
--path) path="${2:?$(error_msg "path is missing")}"; shift 2;;
--path=*) path="${1#*=}"; : "${path:?$(error_msg "path is missing")}"; shift;;
--) shift; break;;
*) break;;
esac
done |
available args: --service ssh,xmpp
--service=ssh,xmpp
--service "ssh xmpp"
--service "ssh,xmpp" So basically anything to fit any need. |
Describe the solution you'd like
I want getopts to parse cli arguments. It will be cleaner.
Describe alternatives you've considered
Additional context
Have no time to do this right now, but it is a medium priority goal.
The text was updated successfully, but these errors were encountered: