Commit Graph

14 Commits

Author SHA1 Message Date
Havoc Pennington
9b44709c89 support -Dconfig.resource, -Dconfig.file, -Dconfig.url system props
These override application.{conf,json,properties} for ConfigFactory.load()
2011-11-30 01:51:36 -05:00
Havoc Pennington
81ce6038c7 remove special-case fallback to system props in substitutions.
The earlier change to make ${user.home} in a file included underneath
"foo" search both ${foo.user.home} and then ${user.home}, means
that even in included files system props are picked up just fine
as long as they were merged into the root config. So there is no
longer any need to have a special-case fallback to system properties.

This leaves ConfigResolveOptions as a really complex way to pass
in a single bool, but of course the point is to allow for future
extension.
2011-11-29 15:46:55 -05:00
Havoc Pennington
53193a48d3 Search for substitutions both included-file-relative and root-relative
This should lay the groundwork for removing the special case fallback
to system properties, and allows included files to look at the reference
configuration.
2011-11-29 15:21:13 -05:00
Havoc Pennington
4f3a91fd86 document why substitutions special-case system props
currently needed for files that are included in other files.

not really happy with how this works now, but documenting it
as a starting point.

maybe to force a substitution to resolve from the root we could
start it with a period? ${.this.is.a.root.prop} ?
2011-11-28 15:11:26 -05:00
Havoc Pennington
9aae9e2a80 Overhaul ConfigFactory API and ConfigFactory.load().
Update all docs and tests.

Add example library and application.
2011-11-28 12:23:21 -05:00
Havoc Pennington
e6ee3d6232 mention using several env vars for one setting in README 2011-11-28 01:37:29 -05:00
Havoc Pennington
789930cd8e Implement Config.checkValid() to check against a reference config
This allows verifying that a config has all the keys it's supposed
to have, and also that they have plausible value types. It uses
a reference config as a kind of very loose schema.

Another benefit is that it can give users a big batch of error
messages at once, rather than one at a time via exceptions
when config settings are used.

Because the reference config is not really a schema, users of
checkValid() may have to tune its behavior by removing some
things from the reference config used for validation, or
ignoring certain errors, or doing additional validation
on their own. But checkValid() is a good basic validator
for all your simple settings and if you have complex
settings you can write additional code to support them
while still using checkValid() for the simple ones.
2011-11-28 01:14:31 -05:00
Havoc Pennington
6ec2681055 missing, optional substitutions ${?foo} become undefined not null
This is more useful behavior because it permits an optional override
for example.
2011-11-27 12:04:44 -05:00
Havoc Pennington
4dddfdaf19 Make ${missing} throw an exception and add ${?missing} for the old behavior.
Also updated the spec; in this patch, the spec says ${?missing} will be
undefined, but the code still evaluates it to null as in the old
behavior. A follow-up patch will introduce the undefined behavior
that is now specified.

This change is needed because missing substitutions are probably
a problem in most cases, and evaluating missing to null is probably
not as useful as evaluating it to undefined. If it turns out that
we need the null behavior, a possible syntax is ${foo.bar,null}
or something like that.
2011-11-27 11:33:10 -05:00
Havoc Pennington
afff7c61ef Explain in README how to take advantage of substitutions 2011-11-22 10:53:35 -05:00
Havoc Pennington
13362f46b4 fix the example API usage in the README 2011-11-18 17:49:40 -05:00
Havoc Pennington
ece196c146 mention foo.bar=10, foo.baz=12 style syntax (single line properties-style) 2011-11-15 23:35:24 -05:00
Havoc Pennington
1841dd9c67 Add a real README, license, and rewrite spec. 2011-11-15 19:14:22 -05:00
Havoc Pennington
00241585bd add an empty README.md 2011-11-10 20:54:53 -05:00