1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// This file is part of helpers4.
// Copyright (C) 2025 baxyz
// SPDX-License-Identifier: LGPL-3.0-or-later
use parse_line;
/// Returns the value of `key` in dotenv `content`, or `None` when it is not assigned.
///
/// When a key is assigned more than once the last assignment wins, like a shell sourcing the
/// file. See [`parse`](super::parse) for the accepted syntax.
///
/// # Arguments
///
/// - `content` - The dotenv text to read.
/// - `key` - The variable name to look up.
///
/// # Examples
///
/// ```
/// use helpers4::env::get;
///
/// let content = "HOST=localhost\nPORT=80\nPORT=8080\n";
/// assert_eq!(get(content, "PORT").as_deref(), Some("8080"));
/// assert_eq!(get(content, "MISSING"), None);
/// ```