I've just started playing around with AppConfig, and I love it!
As I'm working though, I realize there's a bit of a chicken-and-egg problem, and this isn't specific to AppConfig.
Say I want to use hard-coded default values, config file values and command line arg values. I want config file values to override default values and I want command line args to override both defaults and config file values.
The trick is, I want to specify the config file on the command line. That means I need to get the command line first even though it should be last. The obvious solution is to save the command line values somewhere and re-add them after adding the defaults and config file values.
Is there a better way to handle this?
-Thanks
Pileofrogs
Update:
Here's what I've come up with, and yes there is a default config file.
- Set values to default, including name of config file
- Read command line args and store somewhere
- If command line specifies config file, and config file does not exist, blow chunks. (If no config file is specified, and the default config file doesn't exist, that's OK.)
- If command line specifies config file (and we haven't blown chunks yet) set value of config file
- If config file exists, process and set values
- Set values from command line that we stored earlier
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.