Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 14 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,20 @@ struct Config {

### Struct-level Attributes

| Attribute | Description | Example |
|-----------|-------------|---------|
| Attribute | Description | Example |
| ----------------------- | ------------------------------- | ------------------------------- |
| `env_prefix = "PREFIX"` | Set environment variable prefix | `#[Gonfig(env_prefix = "APP")]` |
| `allow_cli` | Enable CLI argument support | `#[Gonfig(allow_cli)]` |
| `allow_config` | Enable config file support | `#[Gonfig(allow_config)]` |
| `allow_cli` | Enable CLI argument support | `#[Gonfig(allow_cli)]` |
| `allow_config` | Enable config file support | `#[Gonfig(allow_config)]` |

### Field-level Attributes

| Attribute | Description | Example |
|-----------|-------------|---------|
| `env_name = "NAME"` | Override environment variable name | `#[gonfig(env_name = "DB_URL")]` |
| `cli_name = "name"` | Override CLI argument name | `#[gonfig(cli_name = "database-url")]` |
| `#[skip]` | Skip field from all sources | `#[skip]` |
| `#[skip_gonfig]` | Alternative skip syntax | `#[skip_gonfig]` |
| Attribute | Description | Example |
| ------------------- | ---------------------------------- | -------------------------------------- |
| `env_name = "NAME"` | Override environment variable name | `#[gonfig(env_name = "DB_URL")]` |
| `cli_name = "name"` | Override CLI argument name | `#[gonfig(cli_name = "database-url")]` |
| `#[skip]` | Skip field from all sources | `#[skip]` |
| `#[skip_gonfig]` | Alternative skip syntax | `#[skip_gonfig]` |

## Skip Attributes

Expand Down Expand Up @@ -258,6 +258,7 @@ ConfigBuilder::new()
Gonfig supports multiple config file formats:

### TOML

```toml
# config.toml
database_url = "postgres://localhost/prod"
Expand All @@ -269,6 +270,7 @@ password = "secret"
```

### YAML

```yaml
# config.yaml
database_url: postgres://localhost/prod
Expand All @@ -279,6 +281,7 @@ mongo:
```

### JSON

```json
{
"database_url": "postgres://localhost/prod",
Expand Down Expand Up @@ -328,27 +331,6 @@ fn main() -> gonfig::Result<()> {

This gives you fine-grained control over logging output without cluttering your application logs.

## Examples

See the [examples/](examples/) directory for more comprehensive examples:

- [`your_usecase.rs`](examples/your_usecase.rs) - Your exact use case implementation
- [`skip_attributes.rs`](examples/skip_attributes.rs) - Comprehensive skip examples
- [`madara_usecase.rs`](examples/madara_usecase.rs) - Complex hierarchical configuration
- [`simple.rs`](examples/simple.rs) - Basic usage example

Run examples:
```bash
# Run with default logging (INFO level)
cargo run --example your_usecase

# Run with debug logging
RUST_LOG=debug cargo run --example skip_attributes

# Run silently (errors only)
RUST_LOG=error cargo run --example simple
```

## Error Handling

Gonfig provides detailed error types:
Expand All @@ -372,9 +354,4 @@ Contributions are welcome! Please feel free to submit a Pull Request.

## License

This project is licensed under either of

* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)

at your option.# gonfig
- MIT license ([LICENSE](LICENSE) or https://opensource.org/licenses/MIT)
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incomplete sentence fragment. The line starts with '- ' suggesting a list item but lacks proper context. Should either be 'This project is licensed under:' followed by the list item, or be a complete sentence like 'This project is licensed under the MIT license'.

Suggested change
- MIT license ([LICENSE](LICENSE) or https://opensource.org/licenses/MIT)
This project is licensed under the MIT license ([LICENSE](LICENSE) or https://opensource.org/licenses/MIT).

Copilot uses AI. Check for mistakes.
Loading