https://github.com/jondotsoy/envuse-rust
Parser to Envuse files.
https://github.com/jondotsoy/envuse-rust
envuse rust-crate
Last synced: about 2 months ago
JSON representation
Parser to Envuse files.
- Host: GitHub
- URL: https://github.com/jondotsoy/envuse-rust
- Owner: JonDotsoy
- License: mit
- Created: 2022-07-27T03:32:01.000Z (almost 3 years ago)
- Default Branch: development
- Last Pushed: 2023-01-22T01:50:13.000Z (over 2 years ago)
- Last Synced: 2025-02-28T12:54:29.985Z (3 months ago)
- Topics: envuse, rust-crate
- Language: Rust
- Homepage: https://crates.io/crates/envuse-parser
- Size: 98.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Envuse Parser
[](https://crates.io/crates/envuse-parser)
[](https://crates.io/crates/envuse-parser)
[](https://crates.io/crates/envuse-parser)
[](https://docs.rs/crate/envuse-parser)Parser to Envuse files.
## The standard library
Envuse definitions describe the rules for writing a file that defines a set of configurations for your project, typically in a file named `.envuse`.
To understand the format, it's necessary to understand some types of tokens:
- Keyword: This is an expression used to describe the name of variables or references. It's a set of characters that start with a letter of the alphabet (`a-z` or `A-Z`) or an underscore (`_`) and can then include numbers (`0-9`).
- Comment: This is an expression that describes anything. The content inside is ignored by the parsers.
- Other symbols: These will be described later because they will be used to describe the behavior.### How to write my first Envuse file
An envuse file expects two different expressions; the block comment is used to describe the next variable expression and the variable expression is used to describe the variable and type expected for your project.
### Variable Expression
This expression is used to describe a variable name and expected type. It starts with a **keyword** to describe the name of your variable. The code samples below show a sample with a variable.
```envuse
ABC
```The expression can also have a definition of type to transform later. This type describes how it might transform the values at runtime, for example when the values are loaded from the environment of the app.
> "I say "might" because it depends on the engine used to run your app, as you can add more transformers."
The type is described just after the variable name and uses a colon symbol. The type is a keyword and is predefined for your app. Below you can see a variable with a type.
```envuse
ABC: String
```Supported types:
- `String`: A literal value read.
- `Number`: Number of 32-bit (See more on [wiki](https://en.wikipedia.org/wiki/32-bit_computing)) ranging from `−2,147,483,648` to `2,147,483,647`.
- `Boolean`: Are values that can be `true` or `false`.### Nullable values
To define a variable as nullable, indicate it with a question mark (?) at the end of the type. You cannot use this symbol if the variable has a default value.
Nullable values are values that might not transform, as they may be undefined in the environment and not have a default value in the envuse file. Below you can see a nullable variable.
```envuse
ABC: String?
```### Default values
Sometimes we want to define a default value for the app if it's not defined in the environment. We can define a default value for any variable by following the variable type, or, if the type isn't defined, after the variable name. Below you can see two samples with default values.
```envuse
ABC = "FOO"
DEF: Number = 3_000
```## LICENSE MIT
This is an open source project with an MIT license for you to enjoy ❤️.