Private/Get-Config.ps1

<#
.SYNOPSIS
    Gets the configuration from config.json
.DESCRIPTION
    Reads and returns the configuration from the workspace config.json file
.PARAMETER WorkspacePath
    Path to the workspace folder. If not provided, uses the stored workspace path.
.OUTPUTS
    PSCustomObject containing the configuration
#>

function Get-Config {
    [CmdletBinding()]
    param(
        [string]$WorkspacePath
    )

    try {
        # Get workspace path from module variable or parameter
        if (-not $WorkspacePath) {
            $WorkspacePath = $script:NLBaselineWorkspacePath
        }

        if (-not $WorkspacePath) {
            throw "Workspace path not configured. Please run Initialize-NLBaseline first."
        }

        $configPath = Join-Path -Path $WorkspacePath -ChildPath "config.json"
        
        if (-not (Test-Path -Path $configPath)) {
            throw "Configuration file not found at: $configPath"
        }

        $config = Get-Content -Path $configPath -Raw | ConvertFrom-Json
        return $config
    }
    catch {
        Write-Error "Failed to get configuration: $_"
        return $null
    }
}