Greetings monks, I am in need of some wisdom from the monastery. I'm creating a script that will look up an (unknown) set of fields from a data source and create a config file. Users will then use this config file to map the fields to either a static string or a variable that I want available as a switch/option when they run the script.
The file would look something like:
ds_field1="A normal string here"
ds_field2=$option1$
ds_field3=$option2$
ds_field4="More words here"
The user would then be able to execute the script as so:
./script --option1 "input for field2" --option2 "input for some other field"
The end game is that the user can customize how these fields map back to the data source, the reason the data source fields are dynamic is because different installs of the data source have potentially different available fields.
The question is: how do I handle dynamic options like this? Right now I'm struggling to think of a sane way to handle the user input/variable mapping aspect.
Edit: Oh! I almost forgot, $option1$ would in reality be some kind of meaningful name. I could just use generic $arg1$, $arg2$, etc type options but in the interest of preserving the sanity of the user I would prefer the names were meaningful (i.e. $hostname$) which is the crux of the problem.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.