Public/Reset-NLBaselineWorkspace.ps1

<#
.SYNOPSIS
    Resets the NLBaseline workspace path
.DESCRIPTION
    Clears the stored workspace path from module settings, allowing re-initialization
.EXAMPLE
    Reset-NLBaselineWorkspace
#>

function Reset-NLBaselineWorkspace {
    [CmdletBinding()]
    param(
        [switch]$Force
    )

    try {
        $moduleDataPath = Join-Path -Path $env:LOCALAPPDATA -ChildPath "NLBaseline"
        $settingsPath = Join-Path -Path $moduleDataPath -ChildPath "settings.json"
        
        if (Test-Path -Path $settingsPath) {
            $settings = Get-Content -Path $settingsPath -Raw | ConvertFrom-Json
            $currentPath = $settings.WorkspacePath
            
            if ($currentPath) {
                if (-not $Force) {
                    Write-Host "Current workspace path: $currentPath" -ForegroundColor Yellow
                    $confirm = Read-Host "Are you sure you want to reset the workspace path? [Y/N]"
                    if ($confirm -ne 'Y' -and $confirm -ne 'y') {
                        Write-Host "Operation cancelled." -ForegroundColor Yellow
                        return
                    }
                }
                
                $settings.WorkspacePath = $null
                $settings.LastUpdated = (Get-Date -Format "yyyy-MM-dd HH:mm:ss")
                $settings | ConvertTo-Json | Set-Content -Path $settingsPath -Force
                
                # Clear module variable
                $script:NLBaselineWorkspacePath = $null
                
                Write-Host "Workspace path has been reset." -ForegroundColor Green
                Write-Host "You can now initialize a new workspace using Initialize-NLBaseline or the Quick Start menu." -ForegroundColor Yellow
            }
            else {
                Write-Host "No workspace path is currently configured." -ForegroundColor Yellow
            }
        }
        else {
            Write-Host "No workspace settings found." -ForegroundColor Yellow
        }
    }
    catch {
        Write-Error "Failed to reset workspace path: $_"
    }
}