Table of Contents

Class EnvironmentHelper

Namespace
Ando.Utilities
Assembly
ando.dll

Shared utilities for environment variable access. Provides consistent error handling for required environment variables.

public static class EnvironmentHelper
Inheritance
EnvironmentHelper
Inherited Members

Methods

Get(string)

Gets an environment variable value, or null if not set.

public static string? Get(string name)

Parameters

name string

Environment variable name.

Returns

string

GetOrDefault(string, string)

Gets an environment variable with a default value if not set.

public static string GetOrDefault(string name, string defaultValue)

Parameters

name string

Environment variable name.

defaultValue string

Value to return if not set.

Returns

string

GetRequired(string, string?)

Gets a required environment variable, throwing if not set.

public static string GetRequired(string name, string? description = null)

Parameters

name string

Environment variable name.

description string

Optional description for clearer error messages.

Returns

string

Exceptions

InvalidOperationException

Thrown when the variable is not set.

GetRequiredOrPrompt(string, string, bool)

Gets a required environment variable, prompting the user if not set. After prompting, sets the environment variable for the current process so subsequent calls and child processes can use it. In non-interactive mode (CI/server), throws an exception instead of prompting.

public static string GetRequiredOrPrompt(string name, string description, bool isSecret = false)

Parameters

name string

Environment variable name.

description string

Description shown in the prompt.

isSecret bool

If true, hides input (for tokens/passwords).

Returns

string

The environment variable value.