|
|
|
|
|
by cturner
3435 days ago
|
|
There's a better alternative: don't have complex usage in the first place. You can get all the functionality you want by having multiple executables calling a common library. Consider netcat. You read the man page, and try to do something following its advice. Often enough, it just doesn't work. Because it's trying to cover a range of unrelated usages through a single entrypoint. It's easy to set up multiple exes cleanly. Have a non-executable module that contains the functions that your application requires (e.g. call it lib.rb). For each distinct usage, create a separate executable script that imports lib.rb, extracts a, b and c from the for just that usage and then call lib.usage(a, b, c). Users will find this easy to discover. You will find it easy to maintain, even compared to dedicated parsing DSLs. We don't special-case functions to do multiple things based on complex argument cases. We just create well-defined functions. We should think of executables in the same terms. |
|