61 Commits

Author SHA1 Message Date
Lukas Kalbertodt
15c729d5f7 Bump version to 0.2.5 2023-12-10 12:20:59 +01:00
Lukas Kalbertodt
fa79a463b8 Add #[config(partial_attr(...))] to add attributes for partial type
CC #17
2023-12-08 18:15:50 +01:00
Lukas Kalbertodt
29a5c05770 Bump version to 0.2.3 2023-03-10 13:07:03 +01:00
Lukas Kalbertodt
2c19c0eed9 Add #![allow(missing_docs)] to generated "partial" mods
This makes sense as we might generated new items that don't have any
docs. Also, we don't forward any docs of the input structs. That we
could change, but I don't think it currently helps in any way. Maybe at
the point when Rust analyzer can fully see and understand the generated
module, then it would make sense to forward docs. But this is the
easier option now.
2023-01-15 18:01:10 +01:00
Lukas Kalbertodt
4f72a14c60 Add docs to generated "partial" mods
This explains their purpose and states that the exact contents are
not stable.
2023-01-15 17:56:26 +01:00
Lukas Kalbertodt
7830f326dd Bump version to 0.2.2 2022-11-25 10:04:47 +01:00
Lukas Kalbertodt
101a60d7ae Use fully qualified paths for all symbols emitted by macro
In particular, `Option`, `Ok`, `None` and `Some` were used without
full path.
2022-11-25 10:00:31 +01:00
Austin Schey
87967d4278 fix: use fully qualified path for results 2022-11-24 18:21:45 -06:00
Lukas Kalbertodt
ad4885032e Bump version to 0.2.1 2022-11-06 12:45:19 +01:00
Lukas Kalbertodt
692ccf10c2 Deduplicate some code 2022-11-06 12:30:01 +01:00
Lukas Kalbertodt
e2dded17fa Change parse_env error type from Debug to impl std::error::Error
This is the more appropriate trait I think and should work well for
most real world use cases.
2022-11-06 11:23:57 +01:00
Lukas Kalbertodt
1e74330f00 Improve formatting slightly 2022-11-06 10:37:58 +01:00
Cyphersnake
cb8f879b92 Add parse_env attribute to confique::Config macro
Since there is no established format for representing collections within env variables, to enable their support, the feature with a custom parser attribute added.

Add helpers for parsing env variables into collections

Improve rustdoc for `env_utils` functions

Improve `parse_env` example
2022-11-06 10:18:42 +04:00
Lukas Kalbertodt
324cedee47 Bump version to 0.2.0 and update changelog 2022-10-21 19:03:49 +02:00
Lukas Kalbertodt
d1a62e47eb Add map default values (e.g. default = { "foo": 33 })
This commit also adds a bunch of tests testing maps in several
situations.
2022-10-21 18:13:59 +02:00
Lukas Kalbertodt
3c75b9a325 Fix type inference error for empty arrays as default values 2022-10-21 16:16:20 +02:00
Lukas Kalbertodt
30fbc4f256 Fix name clash issue of helper deserialize functions 2022-10-17 17:14:01 +02:00
Lukas Kalbertodt
075078ac89 Slightly simplify generated code 2022-10-17 14:50:53 +02:00
Lukas Kalbertodt
4c40a35959 Move code around in macro crate 2022-10-17 11:55:29 +02:00
Lukas Kalbertodt
f0895a8b2f Add support for array default values 2022-10-17 11:29:38 +02:00
Lukas Kalbertodt
0677f751aa Fix bug with float type inference for meta::Expr 2022-10-16 20:13:56 +02:00
Lukas Kalbertodt
5c3315b015 Move to Rust edition 2021 2022-10-14 16:42:49 +02:00
Lukas Kalbertodt
90344ebd36 Bump version to 0.1.4 2022-10-14 16:33:37 +02:00
Lukas Kalbertodt
eb03488973 Fix using env with deserialize_with
Fixes #2

I simply forgot to use the `deserialize_with` attribute for the env
deserialization. The previous code was somewhat weirdly coded in that
we would always deserialize `Option<T>` (as it's a partial type) and
the "env variable not present" info would travel through the
deserializer to the `Option<T> as Deserialize` impl. Now it's more
straight forward.
2022-10-14 16:33:37 +02:00
Lukas Kalbertodt
04f7f6b3be Remove leftover comment 2022-10-11 15:15:09 +02:00
Lukas Kalbertodt
6c35c85008 Bump version to 0.1.3 2022-04-07 17:29:12 +02:00
Lukas Kalbertodt
ed141ab54d Fix generation bug for pub and pub(in path) structs 2022-04-07 13:59:09 +02:00
Lukas Kalbertodt
cc1681bf53 Bump version to 0.1.1 2021-11-03 16:09:13 +01:00
Lukas Kalbertodt
a50f78e938 Add deserialize_with attribute that is forwarded to serde 2021-11-03 16:01:57 +01:00
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