I'm trying to create a script/application which accepts command line arguments when run. Of course, this is a day-to-day thing, but seeing as this is the first time I'm doing it, I'm looking for some guidance. Let's say my script can take these kinds of command line arguments:
script -a -p /path/to/pipe -l mail.Error -m [email protected]
script -a -l mail.Error -m [email protected] -p /path/to/pipe
and so on....
Due to the flexible nature of command line scripts, the arguments you can pass to it can some in a variety of orders and could be missing/have invalid arguments. Now, I know this can be solved by being very strict about how the arguments must show up (first -a, then -p with a path, then -l with a log facility/priority and finally -m with a valid email) and by testing all possible occurrences of them.
But there has to be a better way. This is incredibly inefficient (to me) and I was wondering if there was a better way of doing things. I want to remain as flexible as possible and just make things work instead of focusing on strict usage.