136 Commits

Author SHA1 Message Date
Lukas Kalbertodt
15c729d5f7 Bump version to 0.2.5 v0.2.5 2023-12-10 12:20:59 +01:00
Lukas Kalbertodt
042c78f3ab Allow "yes" & "no" for bool env vars and do case-insensitive matching
Closes #34
2023-12-10 11:11:06 +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
830ca775cb Fix typo in docs 2023-12-08 17:07:07 +01:00
Lukas Kalbertodt
698357332a Remove leftover dummy code in docs 2023-12-08 17:06:10 +01:00
Lukas Kalbertodt
0a79a43a72 Bump version to 0.2.4 0.2.4 2023-07-02 10:17:50 +02:00
Lukas Kalbertodt
4fdfb821dc Fix enum deserialization from env values
Fixes #31
2023-07-02 10:17:49 +02:00
Lukas Kalbertodt
29a5c05770 Bump version to 0.2.3 v0.2.3 2023-03-10 13:07:03 +01:00
Lukas Kalbertodt
20f0379706 Change template::format to not be generic over C
This potentially improves compile times a bit. The only thing the
function needs is the `META` structure of `C`, which can be passed from
the outside. The function is still generic over the formatter, but only
three specific ones are passed. So maybe it's just compiled for those
three already? One might also think about using dynamic dispatch for
the formatter.

Though compile times are likely dominated by all the generated code,
especially the serde-derive code.
2023-03-10 12:58:07 +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
9d6ea4769a Merge pull request #27 from LukasKalbertodt/add-ci-basic-style-check
Add a basic style check to CI
2023-01-15 17:06:04 +01:00
Lukas Kalbertodt
079738be65 Wrap long lines 2023-01-15 17:02:43 +01:00
Lukas Kalbertodt
bd3a803893 Add a basic style check to CI 2023-01-15 17:01:18 +01:00
Lukas Kalbertodt
281e390dd4 Fix CI badge in README 2022-12-25 15:46:32 +01:00
Lukas Kalbertodt
7830f326dd Bump version to 0.2.2 v0.2.2 2022-11-25 10:04:47 +01:00
Lukas Kalbertodt
c6ee971f0d Add test to make sure all emitted symbols use fully qualified paths 2022-11-25 10:00: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
Lukas Kalbertodt
f4e51534c3 Merge pull request #23 from aschey/result-fix
fix: use fully qualified path for results
2022-11-25 09:53:27 +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 v0.2.1 2022-11-06 12:45:19 +01:00
Lukas Kalbertodt
c1ec9477b2 Update to serde 0.9
This is only an internal dependency, so it doesn't require a major
version bump. This also fixes some issues with our tests where the 0.8
version would use a float formatter library that screws up our test
floats.
2022-11-06 12:44:31 +01:00
Lukas Kalbertodt
f1afaa8cc2 Split env module into multiple files 2022-11-06 12:30:06 +01:00
Lukas Kalbertodt
692ccf10c2 Deduplicate some code 2022-11-06 12:30:01 +01:00
Lukas Kalbertodt
bcab519b4a Merge pull request #22 from cyphersnake/10-lists-maps-from-env
Add parse_env attribute
2022-11-06 12:29:43 +01:00
Lukas Kalbertodt
9d57b048ce Improve documentation 2022-11-06 12:26:36 +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
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
337fb3204f Fix some clippy warnings 2022-10-24 10:19:35 +02: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
324cedee47 Bump version to 0.2.0 and update changelog v0.2.0 2022-10-21 19:03:49 +02:00
Lukas Kalbertodt
73796ae676 Adjust README 2022-10-21 18:50:44 +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
093957b515 Add array default value to formatting test example 1 2022-10-21 17:22:03 +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
2e432b1f4a Improve docs 2022-10-21 15:27:29 +02:00
Lukas Kalbertodt
2bf2727875 Mark some types in meta as #[non_exhaustive]
This allows some more likely changes without a breaking change.
2022-10-21 15:27:29 +02:00
Lukas Kalbertodt
52b9369f9a Make all FormatOptions #[non_exhaustive]
This is to make adding fields to those structs a non-breaking change.
This unfortunately means that users cannot use the struct initializer
syntax anymore. They have to create a mutable variable and change fields
that way. It's slightly annoying, but I think we want `non_exhaustive`.

Also, there are multiple discussions and pre-RFCs for letting Rust allow
the struct initializer syntax when the type implements `Default`. So
maybe this will improve in the future.
2022-10-21 14:55:30 +02:00
Lukas Kalbertodt
bc03ecaf4e Remove a bunch of cfg attributes 2022-10-21 13:13:32 +02:00
Lukas Kalbertodt
4533f2b2d4 Fix visibility of template module and items
The trait and `template::format` are now crate-private as I don't want
to expose that API surface (alongside the `TomlFormatter` types).
2022-10-21 12:39:41 +02:00
Lukas Kalbertodt
a784e6ee64 Rename format to template (except template::format()) 2022-10-21 12:02:13 +02:00
Lukas Kalbertodt
9b9610a6ac Add JSON5 support 2022-10-21 11:52:53 +02:00
Lukas Kalbertodt
6a9ccd4e22 Do major refactor of format code
This gets rid of a lot of duplicated logic that was previously
copy&pasted. This commit alos:
- Makes it easier to implement new formats
- Gets rid of a few bugs
- Makes the system more flexible (more options)
- Adds a lot of additional tests
2022-10-19 17:12:32 +02:00
Lukas Kalbertodt
44f59f415a Implement Serialize for meta::Expr and use it in PrintExpr
This probably fixes a few edge case bugs (float infinity and stuff) and
results in less code.
2022-10-19 17:10:17 +02:00
Lukas Kalbertodt
4f5c458150 Add YAML formatting tests 2022-10-19 10:12:25 +02:00
Lukas Kalbertodt
736584ad9d Fix incorrect newlines in yaml::format 2022-10-19 10:11:33 +02:00
Lukas Kalbertodt
dd55a17b14 Show env key in config template 2022-10-18 16:07:51 +02:00
Lukas Kalbertodt
d03d1e0799 Add tests checking many of the standard usages of this lib 2022-10-17 17:55:30 +02:00