Lamg.Env
0.2.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Lamg.Env --version 0.2.0
NuGet\Install-Package Lamg.Env -Version 0.2.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Lamg.Env" Version="0.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Lamg.Env" Version="0.2.0" />
<PackageReference Include="Lamg.Env" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Lamg.Env --version 0.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Lamg.Env, 0.2.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Lamg.Env@0.2.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Lamg.Env&version=0.2.0
#tool nuget:?package=Lamg.Env&version=0.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Lamg.Env
F# library for environment/secret loading, result / taskResult computation expressions, and generic SQLite transaction helpers.
Install
dotnet add package Lamg.Env
Modules
| Module | Purpose |
|---|---|
Lamg.Env.Result |
result and taskResult computation expressions |
Lamg.Env.Secrets |
dotenv.net load + 1Password CLI (op) |
Lamg.Env.Console |
Colored console helpers |
Lamg.Env.Env |
Env vars (getEnv, requireEnv, …) + small time helpers |
Lamg.Env.Sqlite |
Generic dbTxn / nested CE for SQLProvider (or any) contexts |
Secrets
open Lamg.Env.Result
open Lamg.Env.Secrets
loadDotEnv ()
// Prefer local env; fall back to 1Password (same names as field labels)
let! secrets =
resolveFromEnvOrOnePassword [ "API_KEY"; "API_SECRET" ] "my-vault" "my-item"
// Or always load from 1Password and map fields yourself
let! json = getItem "my-vault" "my-item" (Some [ "API_KEY" ])
let! fields = fieldsByLabel json
let apiKey = fields["API_KEY"]
Set OP_SERVICE_ACCOUNT_TOKEN (e.g. in .env) or use an interactive op signin session.
Computation expressions
open Lamg.Env.Result
let work = taskResult {
let! a = Ok 1
let! b = someAsyncWork ()
return a + b
}
SQLite / SQLProvider transactions (Lamg.Env.Sqlite)
No SQLProvider or SQLite package dependency — supply a DbSession<'ctx> that knows how to open and commit your app context:
open Lamg.Env.Sqlite
// Example with a SQLProvider-generated DataContext:
let session: DbSession<MyDb.dataContext> =
{ connect = fun path -> MyDb.GetDataContext($"Data Source={path};Foreign Keys=True")
submitUpdates = fun ctx -> ctx.SubmitUpdates() }
let db = dbTxn session "app.db"
let readDb = readOnlyDbTxn session "app.db"
let! rows = db.Run(fun ctx ->
// stage writes on ctx; outermost successful write Run calls submitUpdates
...)
Semantics:
- Nested
Runon the same DB path reuses the active context when modes allow - Read-only may nest under write; write under read-only →
DbError.ReadWriteInsideReadOnly - Outermost successful read-write run calls
submitUpdates - Per-path write gate serializes outermost write transactions
Develop
dotnet build Lamg.Env.slnx
dotnet run --project Lamg.Env.Tests
dotnet pack Lamg.Env/Lamg.Env.fsproj -c Release
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- dotenv.net (>= 4.0.2)
- Unquote (>= 7.0.1)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Lamg.Env:
| Package | Downloads |
|---|---|
|
MigLib
Package Description |
|
|
MigLib.Codegen
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.