Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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.


In reply to Set getopt defaults based on $0 by samwyse

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-26 02:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found