24 Commits

Author SHA1 Message Date
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
49828fc2e3 Change API of parse_env functions
I think this is an overall improvement. A few things done here:
- They are available as `::env::parse` instead of `::env_utils`. The
  `env` module gets functions of its own soon enough.
- Renamed functions to be shorter: `list_by_sep`, `list_by_comma`, ...
- The docs were adjusted. One example is enough. And the functions with
  a fixed separator don't need the full docs again. That way we can
  avoid the `paste` dependency.
- Functions now always return `Result<C, _>`. While the previous version
  was slightly more flexible, I don't think anyone would benefit from
  that flexibility (as `parse_env` requires `Result<_, _>` anyway) and
  this way it's a bit clearer what the function does, especially for
  those who don't know the nifty `FromIterator for Result` impl.
- The example was adjusted accordingly. I also changed the names to
  obviously dummy names as I didn't know the existing names and don't
  want to spend time investigating whether I want their names in my
  code base :D
2022-11-06 12:26:36 +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
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
0e47eb7acf Format code
This is `cargo fmt` but with lots of changes reverted and some adjusted.
2022-10-24 10:13:06 +02:00
Lukas Kalbertodt
6c9f398065 Allow unused fields in example
This fails now because access by `derive(Debug)` are not counted as
actual reads anymore as far as that lint is concerned.
2022-03-30 17:41:51 +02:00
Lukas Kalbertodt
b7515239e5 Remove useless dev-dependencies 2021-07-28 12:06:04 +02:00
Lukas Kalbertodt
00dbe4dc0a Fix compilation failure for --no-default-features 2021-07-27 17:16:06 +02:00
Lukas Kalbertodt
74ce2daf05 Add Builder::env to read environment variables 2021-07-27 01:14:00 +02:00
Lukas Kalbertodt
db2aebc270 Parse #[env] attribute and representing it in meta types 2021-07-25 11:36:36 +02:00
Lukas Kalbertodt
ca5bb2488f Add Builder type as convenient high level loading API 2021-07-25 09:45:59 +02:00
Lukas Kalbertodt
76373278b0 Remove Source trait and Config::from_sources
I'm not sure about a good high level API.
2021-07-24 22:25:40 +02:00
Lukas Kalbertodt
7561e82215 Update example 2021-07-24 18:48:15 +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
8abc07bcda Add handling of nested configuration types via #[config(child)] 2021-05-14 22:13:31 +02:00
Lukas Kalbertodt
0f37618c19 Rewrite everything to be based on derives (WIP) 2021-05-14 16:30:50 +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
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
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