Public/Invoke-MkLicense.ps1

function Invoke-MkLicense {
    <#
    .SYNOPSIS
    Creates a LICENSE file from a short license stub.
 
    .DESCRIPTION
    Generates a LICENSE file for MIT, Apache-2.0, or GPL-3.0 with TODO placeholders.
    Existing files are not overwritten unless -Force is used.
 
    .PARAMETER Type
    License type to generate. Supported values: MIT, Apache-2.0, GPL-3.0.
 
    .PARAMETER Force
    Overwrites LICENSE if it already exists.
 
    .EXAMPLE
    mklicense -Type MIT
    #>

    [CmdletBinding()]
    [Alias('mklicense')]
    param(
        [Parameter(Mandatory = $true)]
        [ValidateSet('MIT', 'Apache-2.0', 'GPL-3.0')]
        [string]$Type,

        [switch]$Force
    )

    $path = Join-Path -Path (Get-Location) -ChildPath 'LICENSE'

    $content = switch ($Type) {
        'MIT' {
@"
MIT License
 
Copyright (c) TODO_YEAR TODO_OWNER
 
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction.
 
TODO: Replace with full MIT license text.
"@

        }
        'Apache-2.0' {
@"
Apache License
Version 2.0, January 2004
 
Copyright (c) TODO_YEAR TODO_OWNER
 
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
 
TODO: Replace with full Apache-2.0 license text.
"@

        }
        'GPL-3.0' {
@"
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
 
Copyright (c) TODO_YEAR TODO_OWNER
 
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License.
 
TODO: Replace with full GPL-3.0 license text.
"@

        }
    }

    Set-DtFileContent -Path $path -Content $content -Force:$Force | Out-Null

    if (Test-Path -LiteralPath $path) {
        [System.IO.FileInfo]::new($path)
    }
}