lino-env (Rust)
A Rust library to read and write .lenv files.
What is .lenv?
.lenv files are environment configuration files that use : (colon-space) instead of = for key-value separation. This format is part of the links-notation specification.
Example .lenv file:
GITHUB_TOKEN: gh_abc123
TELEGRAM_TOKEN: 054xyz789
API_URL: https://api.example.com:8080
Installation
Add this to your Cargo.toml:
[]
= "0.1"
Usage
Basic Usage
use LinoEnv;
// Create and write a new .lenv file
let mut env = new;
env.set;
env.set;
env.write.unwrap;
// Read an existing .lenv file
let mut env = new;
env.read.unwrap;
// Get a value
if let Some = env.get
Multiple Values per Key
.lenv files support multiple values for the same key:
use LinoEnv;
let mut env = new;
// Add multiple values for the same key
env.add;
env.add;
env.add;
// Get the last value
assert_eq!;
// Get all values
let hosts = env.get_all;
assert_eq!;
Convenience Functions
use ;
use HashMap;
// Write using a HashMap
let mut data = new;
data.insert;
data.insert;
write_lino_env.unwrap;
// Read into a LinoEnv instance
let env = read_lino_env.unwrap;
println!;
API Reference
LinoEnv
new(file_path)- Create a new LinoEnv instanceread()- Read and parse the .lenv filewrite()- Write the current data to the fileget(key)- Get the last value for a keyget_all(key)- Get all values for a keyset(key, value)- Set a key to a single value (replaces all)add(key, value)- Add a value to a key (allows duplicates)has(key)- Check if a key existsdelete(key)- Delete all values for a keykeys()- Get all keysto_hash_map()- Convert to HashMap with last values
License
Unlicense