Public/Invoke-MkReadme.ps1
|
function Invoke-MkReadme { <# .SYNOPSIS Creates a README.md file in the current directory. .DESCRIPTION Generates a README.md using a simple deterministic template with Setup, Usage, and License sections. Existing files are not overwritten unless -Force is used. .PARAMETER Title Title used for the top-level README heading. .PARAMETER Description Optional short description below the title. .PARAMETER Force Overwrites README.md if it already exists. .EXAMPLE mkreadme -Title "My Project" -Description "CLI utilities" #> [CmdletBinding(SupportsShouldProcess = $true)] [OutputType([System.IO.FileInfo])] [Alias('mkreadme')] param( [Parameter(Mandatory = $true)] [string]$Title, [string]$Description = 'TODO: Add project description.', [switch]$Force ) $safeTitle = ConvertTo-DtSafeMarkdownText -Text $Title $safeDescription = ConvertTo-DtSafeMarkdownText -Text $Description $path = Join-Path -Path (Get-Location) -ChildPath 'README.md' if (-not $PSCmdlet.ShouldProcess($path, 'Write README scaffold')) { return } $content = @" # $safeTitle $safeDescription ## Setup TODO: Add setup instructions. ## Usage TODO: Add usage details. ## License TODO: Add license information. "@ Set-DtFileContent -Path $path -Content $content -Force:$Force -Confirm:$false | Out-Null if (Test-Path -LiteralPath $path) { [System.IO.FileInfo]::new($path) } } |