functions/New-EBBookProject.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
function New-EBBookProject
{
<#
    .SYNOPSIS
        Create a new ebook project.
     
    .DESCRIPTION
        Create a new ebook project.
        This project will be designed for authoring in markdown.
        Recommended editor is VSCode, automation requires PowerShell and this module even after creation.
        All three can be installed on any common client Operating System, such as Windows, Linux or MacOS.
     
        It is recommended, but not required, to use a source control service such as GitHub to host your project (for free and not necessarily public).
     
    .PARAMETER Path
        The path where the project should be created.
        Defaults to the current path.
     
    .PARAMETER Name
        The name of the series / book.
        (This project template is designed with a series in mind, but can be used for a single book just as well)
     
    .PARAMETER Author
        The Author of the book.
     
    .PARAMETER Publisher
        The Publisher for this book.
     
    .EXAMPLE
        PS C:\> New-EBBookProject -Name 'Genesis'
     
        Creates a new book project named "Genesis" in the current path.
#>

    [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "")]
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [string]
        $Name,
        
        [PsfValidateScript('PSFramework.Validate.FSPath.Folder', ErrorString = 'PSFramework.Validate.FSPath.Folder')]
        [string]
        $Path = '.',
        
        [string]
        $Author,
        
        [string]
        $Publisher
    )
    
    process
    {
        $parameters = @{
            TemplateName = 'BookProject'
            NoFolder     = $true
            OutPath         = $Path
            Parameters = $PSBoundParameters | ConvertTo-PSFHashtable -Include Name, Author, Publisher
        }
        Invoke-PSMDTemplate @parameters
        Write-PSFMessage -Level Host -Message "Book Project $Name created under $(Resolve-PSFPath $Path)"
    }
}