Commit Graph

32 Commits

Author SHA1 Message Date
Lukas Kalbertodt
a54042f8ca Revert "Replace some manual parsing code with darling helper crate"
This reverts commit e5af4f8efe.

The `darling` crate limits us to `syn::Meta` which is probably not
enough in the long run. There are a couple of other problems I have
with this crate and I think it's currently not worth. I'm considering
writing my own alternative...
2021-11-03 14:58:23 +01:00
Lukas Kalbertodt
e5af4f8efe Replace some manual parsing code with darling helper crate 2021-11-03 11:46:33 +01:00
Lukas Kalbertodt
608b978341 Slightly improve derive error message for nested fields not impl Config 2021-10-26 16:19:33 +02:00
Lukas Kalbertodt
3c5b72220a Improve derive error messages when fields don't implement Deserialize 2021-10-26 16:19:33 +02:00
Lukas Kalbertodt
f0648d722e Prepare macro crate for release 2021-07-28 12:11:32 +02:00
Lukas Kalbertodt
313d143486 Remove Debug impls and syn's extra-trait features 2021-07-28 12:03:43 +02:00
Lukas Kalbertodt
78b2db26e1 Allow multiple attributes in one #[config(...)]
E.g. `#[config(env = "FOO", default = 3)]`
2021-07-27 16:14:49 +02:00
Lukas Kalbertodt
b6046d7f4d Add #[automatically_derive] attribute to emitted impl blocks 2021-07-27 16:14:17 +02:00
Lukas Kalbertodt
aa5eb06f49 Add Partial::from_env and implement it in derive macro 2021-07-27 01:12:57 +02:00
Lukas Kalbertodt
1e0ccf4279 Add check for = or null bytes in env variable key 2021-07-26 22:45:55 +02:00
Lukas Kalbertodt
db2aebc270 Parse #[env] attribute and representing it in meta types 2021-07-25 11:36:36 +02:00
Lukas Kalbertodt
ebd8aba2fa Disallow Option<_> type for fields with #[nested] or #[default]
Regarding nested fields: I cannot imagine a situation where that
distinction is useful. Also, specifying an empty nested object looks
stupid in TOML and YAML anyway.

Regarding default fields: If there is a default value, then the field
should not be declared as optional to begin with.
2021-07-25 10:46:06 +02:00
Lukas Kalbertodt
9c5990d803 Add Partial::is_empty and Partial::is_complete 2021-07-25 10:06:46 +02:00
Lukas Kalbertodt
522494aa5c Fix derive macro for pub(crate) visibility 2021-07-24 18:48:15 +02:00
Lukas Kalbertodt
066e7a0023 Add meta::Field::optional 2021-07-24 18:48:14 +02:00
Lukas Kalbertodt
09cc848b94 Rename #[config(child)] to #[config(nested)] 2021-07-24 18:48:14 +02:00
Lukas Kalbertodt
b71eaa0464 Add Config::META to access the configuration definition at runtime 2021-07-24 18:48:13 +02:00
Lukas Kalbertodt
32fbfd3a5a Add Source trait and implement it for files (TOML and YAML for now) 2021-05-16 15:27:47 +02:00
Lukas Kalbertodt
6d1e9e99c6 Add #[default = "confique::Partial::empty"] attributes to child fields
That was they can be missing in the config source without causing a
deserialization error.
2021-05-16 14:57:44 +02:00
Lukas Kalbertodt
8abc07bcda Add handling of nested configuration types via #[config(child)] 2021-05-14 22:13:31 +02:00
Lukas Kalbertodt
3fd3835fdf Error on unexpected extra tokens in attribute 2021-05-14 21:23:39 +02:00
Lukas Kalbertodt
0f37618c19 Rewrite everything to be based on derives (WIP) 2021-05-14 16:30:50 +02:00
Lukas Kalbertodt
0fcf36fd81 Remove requirement of having either an example or a default value
It's fine not having either. We can just render `#key =` in the
template.
2021-04-30 18:00:05 +02:00
Lukas Kalbertodt
c798049443 Require single config root object
Otherwise global attributes and attributes for the root object have the
same syntax (`#![...]`). This way, it is way clearer.
2021-04-30 17:51:06 +02:00
Lukas Kalbertodt
5075b4df17 Add derive_for_all global attribute (defaulting to Debug)
In most cases, I expect that users just want all structs to derive
`Debug` or maybe also `Clone`.
2021-04-29 23:45:40 +02:00
Lukas Kalbertodt
651a06b252 Add typename attribute and refactor a bunch
This commit should have been two, I know. I feel bad about it.
2021-04-29 23:18:22 +02:00
Lukas Kalbertodt
5d3ccd7b42 Add support for #[derive] annotations 2021-04-29 20:19:25 +02:00
Lukas Kalbertodt
32f05abdca Add missing visibility modifier 2021-04-29 19:46:51 +02:00
Lukas Kalbertodt
24dec3b037 Add #![visibility = "..."] attribute to specify visibility 2021-04-29 19:30:19 +02:00
Lukas Kalbertodt
bfab0e8798 Add example module for documentation
It currently doesn't show anything as all items are pub(crate).
2021-04-29 19:00:36 +02:00
Lukas Kalbertodt
1ae45a3e7c Move TryFromError from generated code into main crate
There is not really a point in generating this type for every
invocation. Also reduces the number of things magically generated.
2021-04-29 18:41:17 +02:00
Lukas Kalbertodt
537a8b7725 Add version from other project
This was mostly what I implemented as utility library for another
project. But I figured I can also extract it as it's useful on its
own.
2021-04-29 18:09:26 +02:00