samwyse has asked for the wisdom of the Perl Monks concerning the following question:
Let's say that 'bheerdb' is an interface to an external data store. It has a bunch of options that are typically used in a few standard patterns. I'd like to save a bunch of typing by aliasing 'bheerdb' to various names and using $0 to set appropriate defaults for getopt. For example, 'create-tap duff' should set defaults '--action create' and '--type domestic', while 'update-tap --class premium duff' should only set a default of '--action update'.
The aliases I'm using are all 'verb-objtype' and some defaults depend on the verb, some on objtype, and a few actually depend on both. I guess I need some sort of decision table, but Re^3: Burned by precedence rules is the only Perlmonks discussion that even mentions the subject. I don't want to write a bunch of wrapper scripts, because I occasionally need to change the default values, and I don't want to have to change a bunch of scripts. So if anyone has any ideas, I'd appreciate hearing them.
BTW, as I was writing my question, I realized that what I need is similar to something usually found in text adventure games, where there's a generic response to some commands, which can be overridden by both the object and the room you're in. I guess I'll look into that as well.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Set getopt defaults based on $0
by tilly (Archbishop) on Jan 13, 2011 at 18:04 UTC | |
Re: Set getopt defaults based on $0
by ikegami (Patriarch) on Jan 13, 2011 at 17:56 UTC | |
Re: Set getopt defaults based on $0
by hsinclai (Deacon) on Jan 13, 2011 at 17:45 UTC | |
by samwyse (Scribe) on Dec 09, 2020 at 21:57 UTC | |
Re: Set getopt defaults based on $0
by Anonyrnous Monk (Hermit) on Jan 13, 2011 at 18:58 UTC |