Private/New-ReadMe.ps1
Function New-ReadMe { <# .SYNOPSIS Creates a basic README.md file for a project. .DESCRIPTION This function generates a basic README.md file, including a placeholder for a status badge and a header with the project's name. .PARAMETER Path Required. Specifies the absolute path where the README.md file will be created. .PARAMETER Name Required. The name of the project. This will be used in the main header of the README.md file. .EXAMPLE New-ReadMe -Path C:\MyProject -Name MyModule This creates a file named "README.md" in the "C:\MyProject" directory. .NOTES Author: owen.heaume Version: 1.0.0 - Initial release #> [CmdletBinding()] param ( [Parameter(Mandatory)] [string]$Path, [Parameter(Mandatory)] [string]$Name ) Begin {} Process { $readMePath = Join-Path -Path $Path -ChildPath "README.md" $readMeContent = @" <Status badge goes Here> # $Name "@ try { Write-Host "Creating README.md file: $readMePath" -ForegroundColor DarkCyan if (Test-Path $readMePath) { Write-Host "README.md file already exists" -ForegroundColor DarkYellow } else { $readMeContent | Out-File -FilePath $readMePath -ea Stop Write-Host "README.md file created successfully" -ForegroundColor DarkGreen } } catch { throw "Error writing README.md file: $_" } } End {} } |