diff --git a/Test/helper/module.helper.ps1 b/Test/helper/module.helper.ps1 new file mode 100644 index 0000000..670d090 --- /dev/null +++ b/Test/helper/module.helper.ps1 @@ -0,0 +1,190 @@ +# Helper for module variables + +function Find-ModuleRootPath{ + [CmdletBinding()] + param( + [Parameter(Mandatory,ValueFromPipeline,Position = 0)] + [string]$Path + ) + + $path = Convert-Path -Path $Path + + while (-not [string]::IsNullOrWhiteSpace($Path)){ + $psd1 = Get-ChildItem -Path $Path -Filter *.psd1 | Select-Object -First 1 + + if ($psd1 | Test-Path) { + + if($psd1.BaseName -eq "Test"){ + #foudn testing module. Continue + $path = $path | Split-Path -Parent + continue + } + + # foudn module + return $path + } + # folder without psd1 file + $path = $path | Split-Path -Parent + } + + # Path is null. Reached driver root. Module not found + return $null +} + +$MODULE_ROOT_PATH = $PSScriptRoot | Find-ModuleRootPath +$MODULE_NAME = (Get-ChildItem -Path $MODULE_ROOT_PATH -Filter *.psd1 | Select-Object -First 1).BaseName + +# Helper for module variables + +# Folders names that IncludeHelper may add content to +$VALID_INCLUDE_FOLDER_NAMES = @( + 'Root', + 'Include', + 'DevContainer', + 'WorkFlows', + 'GitHub', + # 'Config', + 'Helper', + # 'Private', + # 'Public', + 'Tools', + + 'TestRoot', + # 'TestConfig' + 'TestInclude', + 'TestHelper', + # 'TestPrivate', + # 'TestPublic', + + "TestHelperRoot", + "TestHelperPrivate", + "TestHelperPublic" + + "VsCode" +) + +# Folders names that IncludeHelper should not add content to. +# In this folders is the module code itself +$VALID_MODULE_FOLDER_NAMES = @( + 'Config', + 'Private', + 'Public', + 'TestConfig' + 'TestPrivate', + 'TestPublic' +) + +$VALID_FOLDER_NAMES = $VALID_INCLUDE_FOLDER_NAMES + $VALID_MODULE_FOLDER_NAMES + +class ValidFolderNames : System.Management.Automation.IValidateSetValuesGenerator { + [String[]] GetValidValues() { + return $script:VALID_FOLDER_NAMES + } +} + +function Get-Ps1FullPath{ + [CmdletBinding()] + param( + [Parameter(Mandatory,Position = 0)][string]$Name, + [Parameter(Position = 1)][ValidateSet([ValidFolderNames])][string]$FolderName, + [Parameter(Position = 0)][string]$ModuleRootPath + ) + + # If folderName is not empty + if($FolderName -ne $null){ + $folder = Get-ModuleFolder -FolderName $FolderName -ModuleRootPath $ModuleRootPath + $path = $folder | Join-Path -ChildPath $Name + } else { + $path = $Name + } + + # Check if file exists + if(-Not (Test-Path $path)){ + throw "File $path not found" + } + + # Get Path item + $item = Get-item -Path $path + + return $item +} +function Get-ModuleRootPath{ + [CmdletBinding()] + param( + [Parameter(Position = 0)][string]$ModuleRootPath + ) + + # if ModuleRootPath is not provided, default to local module path + if([string]::IsNullOrWhiteSpace($ModuleRootPath)){ + $ModuleRootPath = $MODULE_ROOT_PATH + } + + # Convert to full path + $ModuleRootPath = Convert-Path -Path $ModuleRootPath + + return $ModuleRootPath +} + +function Get-ModuleName{ + [CmdletBinding()] + param( + [Parameter(Position = 0)] [string]$ModuleRootPath + ) + + $ModuleRootPath = Get-ModuleRootPath -ModuleRootPath $ModuleRootPath + + $MODULE_NAME = (Get-ChildItem -Path $MODULE_ROOT_PATH -Filter *.psd1 | Select-Object -First 1).BaseName + + + return $MODULE_NAME +} + +function Get-ModuleFolder{ + [CmdletBinding()] + param( + [Parameter(Mandatory,Position = 0)][ValidateSet([ValidFolderNames])][string]$FolderName, + [Parameter(Position = 1)][string]$ModuleRootPath + ) + + $ModuleRootPath = Get-ModuleRootPath -ModuleRootPath $ModuleRootPath + + # TestRootPath + $testRootPath = $ModuleRootPath | Join-Path -ChildPath "Test" + $testHelperRootPath = $ModuleRootPath | Join-Path -ChildPath "tools/Test_Helper" + + switch ($FolderName){ + + # VALID_INCLUDE_FOLDER_NAMES + 'Root' { $moduleFolder = $ModuleRootPath } + 'Include' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath "include" } + 'DevContainer'{ $moduleFolder = $ModuleRootPath | Join-Path -ChildPath ".devcontainer" } + 'WorkFlows' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath ".github/workflows" } + 'GitHub' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath ".github" } + 'Helper' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath "helper" } + 'Tools' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath "tools" } + + 'TestRoot' { $moduleFolder = $testRootPath } + 'TestInclude' { $moduleFolder = $testRootPath | Join-Path -ChildPath "include" } + 'TestHelper' { $moduleFolder = $testRootPath | Join-Path -ChildPath "helper" } + + 'TestHelperRoot' { $moduleFolder = $testHelperRootPath } + 'TestHelperPrivate' { $moduleFolder = $testHelperRootPath | Join-Path -ChildPath "private" } + 'TestHelperPublic' { $moduleFolder = $testHelperRootPath | Join-Path -ChildPath "public" } + + "VsCode" { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath ".vscode" } + + # VALID_MODULE_FOLDER_NAMES + 'Config' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath "config" } + 'Private' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath "private" } + 'Public' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath "public" } + 'TestConfig' { $moduleFolder = $testRootPath | Join-Path -ChildPath "config" } + 'TestPrivate' { $moduleFolder = $testRootPath | Join-Path -ChildPath "private" } + 'TestPublic' { $moduleFolder = $testRootPath | Join-Path -ChildPath "public" } + + + default{ + throw "Folder [$FolderName] is unknown" + } + } + return $moduleFolder +} Export-ModuleMember -Function Get-ModuleFolder \ No newline at end of file diff --git a/helper/module.helper.ps1 b/helper/module.helper.ps1 new file mode 100644 index 0000000..670d090 --- /dev/null +++ b/helper/module.helper.ps1 @@ -0,0 +1,190 @@ +# Helper for module variables + +function Find-ModuleRootPath{ + [CmdletBinding()] + param( + [Parameter(Mandatory,ValueFromPipeline,Position = 0)] + [string]$Path + ) + + $path = Convert-Path -Path $Path + + while (-not [string]::IsNullOrWhiteSpace($Path)){ + $psd1 = Get-ChildItem -Path $Path -Filter *.psd1 | Select-Object -First 1 + + if ($psd1 | Test-Path) { + + if($psd1.BaseName -eq "Test"){ + #foudn testing module. Continue + $path = $path | Split-Path -Parent + continue + } + + # foudn module + return $path + } + # folder without psd1 file + $path = $path | Split-Path -Parent + } + + # Path is null. Reached driver root. Module not found + return $null +} + +$MODULE_ROOT_PATH = $PSScriptRoot | Find-ModuleRootPath +$MODULE_NAME = (Get-ChildItem -Path $MODULE_ROOT_PATH -Filter *.psd1 | Select-Object -First 1).BaseName + +# Helper for module variables + +# Folders names that IncludeHelper may add content to +$VALID_INCLUDE_FOLDER_NAMES = @( + 'Root', + 'Include', + 'DevContainer', + 'WorkFlows', + 'GitHub', + # 'Config', + 'Helper', + # 'Private', + # 'Public', + 'Tools', + + 'TestRoot', + # 'TestConfig' + 'TestInclude', + 'TestHelper', + # 'TestPrivate', + # 'TestPublic', + + "TestHelperRoot", + "TestHelperPrivate", + "TestHelperPublic" + + "VsCode" +) + +# Folders names that IncludeHelper should not add content to. +# In this folders is the module code itself +$VALID_MODULE_FOLDER_NAMES = @( + 'Config', + 'Private', + 'Public', + 'TestConfig' + 'TestPrivate', + 'TestPublic' +) + +$VALID_FOLDER_NAMES = $VALID_INCLUDE_FOLDER_NAMES + $VALID_MODULE_FOLDER_NAMES + +class ValidFolderNames : System.Management.Automation.IValidateSetValuesGenerator { + [String[]] GetValidValues() { + return $script:VALID_FOLDER_NAMES + } +} + +function Get-Ps1FullPath{ + [CmdletBinding()] + param( + [Parameter(Mandatory,Position = 0)][string]$Name, + [Parameter(Position = 1)][ValidateSet([ValidFolderNames])][string]$FolderName, + [Parameter(Position = 0)][string]$ModuleRootPath + ) + + # If folderName is not empty + if($FolderName -ne $null){ + $folder = Get-ModuleFolder -FolderName $FolderName -ModuleRootPath $ModuleRootPath + $path = $folder | Join-Path -ChildPath $Name + } else { + $path = $Name + } + + # Check if file exists + if(-Not (Test-Path $path)){ + throw "File $path not found" + } + + # Get Path item + $item = Get-item -Path $path + + return $item +} +function Get-ModuleRootPath{ + [CmdletBinding()] + param( + [Parameter(Position = 0)][string]$ModuleRootPath + ) + + # if ModuleRootPath is not provided, default to local module path + if([string]::IsNullOrWhiteSpace($ModuleRootPath)){ + $ModuleRootPath = $MODULE_ROOT_PATH + } + + # Convert to full path + $ModuleRootPath = Convert-Path -Path $ModuleRootPath + + return $ModuleRootPath +} + +function Get-ModuleName{ + [CmdletBinding()] + param( + [Parameter(Position = 0)] [string]$ModuleRootPath + ) + + $ModuleRootPath = Get-ModuleRootPath -ModuleRootPath $ModuleRootPath + + $MODULE_NAME = (Get-ChildItem -Path $MODULE_ROOT_PATH -Filter *.psd1 | Select-Object -First 1).BaseName + + + return $MODULE_NAME +} + +function Get-ModuleFolder{ + [CmdletBinding()] + param( + [Parameter(Mandatory,Position = 0)][ValidateSet([ValidFolderNames])][string]$FolderName, + [Parameter(Position = 1)][string]$ModuleRootPath + ) + + $ModuleRootPath = Get-ModuleRootPath -ModuleRootPath $ModuleRootPath + + # TestRootPath + $testRootPath = $ModuleRootPath | Join-Path -ChildPath "Test" + $testHelperRootPath = $ModuleRootPath | Join-Path -ChildPath "tools/Test_Helper" + + switch ($FolderName){ + + # VALID_INCLUDE_FOLDER_NAMES + 'Root' { $moduleFolder = $ModuleRootPath } + 'Include' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath "include" } + 'DevContainer'{ $moduleFolder = $ModuleRootPath | Join-Path -ChildPath ".devcontainer" } + 'WorkFlows' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath ".github/workflows" } + 'GitHub' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath ".github" } + 'Helper' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath "helper" } + 'Tools' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath "tools" } + + 'TestRoot' { $moduleFolder = $testRootPath } + 'TestInclude' { $moduleFolder = $testRootPath | Join-Path -ChildPath "include" } + 'TestHelper' { $moduleFolder = $testRootPath | Join-Path -ChildPath "helper" } + + 'TestHelperRoot' { $moduleFolder = $testHelperRootPath } + 'TestHelperPrivate' { $moduleFolder = $testHelperRootPath | Join-Path -ChildPath "private" } + 'TestHelperPublic' { $moduleFolder = $testHelperRootPath | Join-Path -ChildPath "public" } + + "VsCode" { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath ".vscode" } + + # VALID_MODULE_FOLDER_NAMES + 'Config' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath "config" } + 'Private' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath "private" } + 'Public' { $moduleFolder = $ModuleRootPath | Join-Path -ChildPath "public" } + 'TestConfig' { $moduleFolder = $testRootPath | Join-Path -ChildPath "config" } + 'TestPrivate' { $moduleFolder = $testRootPath | Join-Path -ChildPath "private" } + 'TestPublic' { $moduleFolder = $testRootPath | Join-Path -ChildPath "public" } + + + default{ + throw "Folder [$FolderName] is unknown" + } + } + return $moduleFolder +} Export-ModuleMember -Function Get-ModuleFolder \ No newline at end of file diff --git a/include/MyWrite.ps1 b/include/MyWrite.ps1 new file mode 100644 index 0000000..7e8ffbb --- /dev/null +++ b/include/MyWrite.ps1 @@ -0,0 +1,205 @@ +# Include MyWrite.ps1 +# Provides Write-MyError, Write-MyWarning, Write-MyVerbose, Write-MyHost, Write-MyDebug +# and Test-MyVerbose, Test-MyDebug functions for consistent logging and debugging output. +# Use env variables ModuleHelper_VERBOSE and ModuleHelper_DEBUG to control verbosity and debug output. +# Example: $env:ModuleHelper_DEBUG="all" or $env:ModuleHelper_DEBUG="Sync-Project" + +$ModuleRootPath = Get-ModuleRootPath -ModuleRootPath $ModuleRootPath +$MODULE_NAME = (Get-ChildItem -Path $ModuleRootPath -Filter *.psd1 | Select-Object -First 1).BaseName + +$ERROR_COLOR = "Red" +$WARNING_COLOR = "Yellow" +$VERBOSE_COLOR = "DarkYellow" +$OUTPUT_COLOR = "DarkCyan" +$DEBUG_COLOR = "DarkGray" + +function Write-MyError { + [CmdletBinding()] + [Alias("Write-Error")] + param( + [Parameter(Mandatory, ValueFromPipeline)][string]$Message + ) + # Write-Host "Error: $message" -ForegroundColor $ERROR_COLOR + Write-ToConsole "Error: $message" -Color $ERROR_COLOR +} + +function Write-MyWarning { + [CmdletBinding()] + [Alias("Write-Warning")] + param( + [Parameter(Mandatory, ValueFromPipeline)][string]$Message + ) + # Write-Host "Error: $message" -ForegroundColor $WARNING_COLOR + Write-ToConsole $message -Color $WARNING_COLOR +} + +function Write-MyVerbose { + [CmdletBinding()] + [Alias("Write-Verbose")] + param( + [Parameter(ValueFromPipeline)][string]$Message + ) + + if (Test-MyVerbose) { + Write-ToConsole $message -Color $VERBOSE_COLOR + } +} + +function Write-MyHost { + [CmdletBinding()] + [Alias("Write-Host")] + param( + [Parameter(ValueFromPipeline)][string]$Message, + [Parameter()][string]$ForegroundColor = $OUTPUT_COLOR, + [Parameter()][switch]$NoNewLine + ) + # Write-Host $message -ForegroundColor $OUTPUT_COLOR + Write-ToConsole $message -Color $ForegroundColor -NoNewLine:$NoNewLine +} + +function Write-MyDebug { + [CmdletBinding()] + [Alias("Write-Debug")] + param( + [Parameter(Position = 0)][string]$section, + [Parameter(Position = 1, ValueFromPipeline)][string]$Message, + [Parameter(Position = 2)][object]$Object + ) + + process{ + + if (Test-MyDebug -section $section) { + + if ($Object) { + $objString = $Object | Get-ObjetString + $message = $message + " - " + $objString + } + $timestamp = Get-Date -Format 'HH:mm:ss.fff' + "[$timestamp][D][$section] $message" | Write-ToConsole -Color $DEBUG_COLOR + } + } +} + +function Write-ToConsole { + param( + [Parameter(ValueFromPipeline)][string]$Color, + [Parameter(ValueFromPipeline, Position = 0)][string]$Message, + [Parameter()][switch]$NoNewLine + + ) + if([string]::IsNullOrWhiteSpace($Color)){ + Microsoft.PowerShell.Utility\Write-Host $message -NoNewLine:$NoNewLine + } else { + Microsoft.PowerShell.Utility\Write-Host $message -ForegroundColor:$Color -NoNewLine:$NoNewLine + } + +} + + +function Test-MyVerbose { + param( + [Parameter(Position = 0)][string]$section + ) + + $moduleDebugVarName = $MODULE_NAME + "_VERBOSE" + $flag = [System.Environment]::GetEnvironmentVariable($moduleDebugVarName) + + if ([string]::IsNullOrWhiteSpace( $flag )) { + return $false + } + + $trace = ($flag -like '*all*') -or ( $section -like "*$flag*") + return $trace +} + +function Enable-ModuleNameVerbose{ + param( + [Parameter(Position = 0)][string]$section + ) + + if( [string]::IsNullOrWhiteSpace( $section )) { + $flag = "all" + } else { + $flag = $section + } + + $moduleDebugVarName = $MODULE_NAME + "_VERBOSE" + [System.Environment]::SetEnvironmentVariable($moduleDebugVarName, $flag) +} +Copy-Item -path Function:Enable-ModuleNameVerbose -Destination Function:"Enable-$($MODULE_NAME)Verbose" +Export-ModuleMember -Function "Enable-$($MODULE_NAME)Verbose" + +function Disable-ModuleNameVerbose{ + param() + + $moduleDebugVarName = $MODULE_NAME + "_VERBOSE" + [System.Environment]::SetEnvironmentVariable($moduleDebugVarName, $null) +} +Copy-Item -path Function:Disable-ModuleNameVerbose -Destination Function:"Disable-$($MODULE_NAME)Verbose" +Export-ModuleMember -Function "Disable-$($MODULE_NAME)Verbose" + +function Test-MyDebug { + param( + [Parameter(Position = 0)][string]$section + ) + + # Get the module debug environment variable + $moduleDebugVarName = $MODULE_NAME + "_DEBUG" + $flag = [System.Environment]::GetEnvironmentVariable($moduleDebugVarName) + + # check if debugging is enabled + if ([string]::IsNullOrWhiteSpace( $flag )) { + return $false + } + + $flag = $flag.ToLower() + $section = $section.ToLower() + + $trace = ($flag -like '*all*') -or ( $section -like "*$flag*") + return $trace +} + +function Enable-ModuleNameDebug{ + param( + [Parameter(Position = 0)][string]$section + ) + + if( [string]::IsNullOrWhiteSpace( $section )) { + $flag = "all" + } else { + $flag = $section + } + + $moduleDebugVarName = $MODULE_NAME + "_DEBUG" + [System.Environment]::SetEnvironmentVariable($moduleDebugVarName, $flag) +} +Copy-Item -path Function:Enable-ModuleNameDebug -Destination Function:"Enable-$($MODULE_NAME)Debug" +Export-ModuleMember -Function "Enable-$($MODULE_NAME)Debug" + +function Disable-ModuleNameDebug { + param() + + $moduleDebugVarName = $MODULE_NAME + "_DEBUG" + [System.Environment]::SetEnvironmentVariable($moduleDebugVarName, $null) +} +Copy-Item -path Function:Disable-ModuleNameDebug -Destination Function:"Disable-$($MODULE_NAME)Debug" +Export-ModuleMember -Function "Disable-$($MODULE_NAME)Debug" + +function Get-ObjetString { + param( + [Parameter(ValueFromPipeline, Position = 0)][object]$Object + ) + + process{ + + if ($null -eq $Object) { + return "null" + } + + if ($Object -is [string]) { + return $Object + } + + return $Object | ConvertTo-Json -Depth 10 -ErrorAction SilentlyContinue + } +} diff --git a/public/newNotes.ps1 b/public/newNotes.ps1 index 9f8f027..09a7b16 100644 --- a/public/newNotes.ps1 +++ b/public/newNotes.ps1 @@ -153,166 +153,136 @@ function New-NoteToday{ [Parameter()][switch] $Force, [Parameter()][string] $RootPath ) + $params = @{ + Category = $Category + Section = $Section + Title = $Title + Date = "" + Notes = $Notes + IssueUrl = $IssueUrl + Template = "none" + NoOpen = $NoOpen + AddNoteFolder = $AddNoteFolder + Force = $Force + RootPath = $RootPath + DateToday = $true + + } - $ret = New-Note ` - -Category $Category ` - -Section $Section ` - -Title $Title ` - -Notes $Notes ` - -IssueUrl $IssueUrl ` - -Template $Template ` - -NoOpen:$NoOpen ` - -AddNoteFolder:$AddNoteFolder ` - -Force:$Force ` - -RootPath $RootPath ` - -DateToday + $ret = New-Note @params return $ret } Export-ModuleMember -Function New-NoteToday -Alias "note" -# function New-NoteToday{ -# # Add Force parameter to support creation of client folder if it doesn't exist -# [CmdletBinding()] -# [alias("note")] -# param( -# [Parameter(Mandatory,Position = 0)][string] $Category, -# [Parameter(Mandatory,Position = 1)][string] $Title, -# [Parameter()][string] $Section, -# [Parameter()][string] $Notes, -# [Parameter()][string] $IssueUrl, -# [Parameter()][string] [ValidateSet("none","meetingmini")] $Template = "none", -# [Parameter()][switch] $NoOpen, -# [Parameter()][switch] $AddNoteFolder, -# [Parameter()][switch] $Force, -# [Parameter()][string] $RootPath, -# [Parameter()][string] $Date -# ) - -# # FILENAME - -# $folder = Get-NoteFolder -RootPath $RootPath -Category $Category -Section $Section -Force:$Force - -# if(-Not $folder) { -# Write-Error "Failed to create the folder for the note. Try -Force." -# return -# } - -# if(-Not (Test-Path -Path $folder)) { -# Write-Error "Base folder for note does not exist '$folder'. Try -Force." -# return -# } - -# # Extract just the folder name from the path -# $today = if([string]::IsNullOrWhiteSpace($Date)) { Get-Date -Format "yyMMdd" } else { $Date } - -# $header = [string]::IsNullOrWhiteSpace($Section) ? $Category : $Section - -# # Create FullTitle using folder name and title, replacing spaces with underscores -# $fullTitle = "{0}-{1}-{2}" -f $today, $header, $Title +function New-NoteTodayClient{ + [CmdletBinding()] + [alias("cnote")] + param( + [Parameter(Mandatory,Position = 0)][string] $Name, + [Parameter(Mandatory,Position = 1)][string] $Title, + [Parameter(Position = 2)][string] $Notes, + [Parameter(ValueFromPipeline)][string] $IssueUrl, + [Parameter()][switch] $NoOpen, + [Parameter()][switch] $Force, + [Parameter()][string] $RootPath -# # Normilize fullTitle by removing special characters and replacing spaces with underscores -# $fullTitle = $fullTitle -replace '\s+', '_' + ) -# # Create the note base folder + $params = @{ + Category = "Clients" + Section = $Name + Title = $Title + Date = "" + Notes = $Notes + IssueUrl = $IssueUrl + Template = "meetingmini" + NoOpen = $NoOpen + Force = $Force + RootPath = $RootPath + AddNoteFolder = $false + DateToday = $true + } -# if($AddNoteFolder){ -# # Create full path for the note file -# $noteFolder = Join-Path -Path $folder -ChildPath $fullTitle - -# if (-not (Test-Path -Path $noteFolder)) { -# New-Item -Path $noteFolder -ItemType Directory -Force | Out-Null -# Write-Verbose "Created note folder: $noteFolder" -# } - -# $fullPath =$noteFolder | Join-Path -ChildPath "$fullTitle.md" -# } else { -# # use folder as the parent folder of the note -# $fullPath = Join-Path -Path $folder -ChildPath "$fullTitle.md" -# } - -# # Check if file already exists -# if (-Not (Test-Path -Path $fullPath)) { - -# # Get template content -# $content = Get-TemplatePath $Template | Get-FileContent - -# # Replace placeholders in the template with actual values -# $content = $content -replace '{title}' , $Title -# $content = $content -replace '{header}' , $header -# $content = $content -replace '{date}' , $today -# $content = $content -replace '{notes}' , ([string]::IsNullOrWhiteSpace($Notes) ? '-' : $Notes) -# $content = $content -replace '{issueurl}' , ([string]::IsNullOrWhiteSpace($IssueUrl) ? '' : $IssueUrl) - - -# # If $Force check that the folders of $fullPath exists and if not create it -# if ($Force) { -# $parentFolder = Split-Path -Path $fullPath -Parent -# if (-Not (Test-Path -Path $parentFolder)) { -# New-Item -Path $parentFolder -ItemType Directory -Force | Out-Null -# Write-Verbose "Created folder: $parentFolder" -# } -# } - -# # Create the file with content -# Set-Content -Path $fullPath -Value $content -Force -# } - -# if( -not $NoOpen) { -# # Open file in VS Code with cursor at the end -# $gotocmd = "{0}{1}" -f $fullPath, ":9999" -# code --goto $gotocmd -# } + $ret = New-Note @params -# # Return file just created -# return $fullPath + return $ret -# } Export-ModuleMember -Function New-NoteToday -Alias "note" +} Export-ModuleMember -Function New-NoteTodayClient -Alias cnote -function New-NoteTodayClient{ +function New-NoteTodayMeeting{ [CmdletBinding()] - [alias("cnote")] + [alias("mnote")] param( [Parameter(Mandatory,Position = 0)][string] $Name, [Parameter(Mandatory,Position = 1)][string] $Title, [Parameter(Position = 2)][string] $Notes, - [Parameter(ValueFromPipeline)][string] $IssueUrl, + [Parameter()][string] $IssueUrl, [Parameter()][switch] $NoOpen, - [Parameter()][switch] $Force + [Parameter()][switch] $Force, + [Parameter()][string] $RootPath ) - begin { - $category = "Clients" - $section = $Name + $params = @{ + Category = "meetings" + Section = $Name + Title = $Title + Date = "" + Notes = $Notes + IssueUrl = $IssueUrl + Template = "meetingmini" + NoOpen = $NoOpen + Force = $Force + RootPath = $RootPath + AddNoteFolder = $false + DateToday = $true } - process{ + $ret = New-Note @params - $folder = Get-NoteFolder -Category $category -Section $section -Force:$Force + return $ret - if (-not $folder) { - Write-Error "Client folder for '$section' does not exist and Force was not specified." - return - } +} Export-ModuleMember -Function New-NoteTodayMeeting -Alias mnote - New-NoteToday ` - -Category $category ` - -Section $section ` - -Title $Title ` - -Notes $Notes ` - -IssueUrl $IssueUrl ` - -Template "meetingmini" ` - -NoOpen:$NoOpen +function New-NoteMeetingNext{ + [CmdletBinding()] + [alias("mnoten")] + param( + [Parameter(Mandatory,Position = 0)][string] $Name, + [Parameter(Position = 1)][string] $Notes, + [Parameter()][string] $IssueUrl, + [Parameter()][switch] $NoOpen, + [Parameter()][switch] $Force, + [Parameter()][string] $RootPath + ) + + $params = @{ + Category = "meetings" + Section = $Name + Title = "Next Meeting Notes" + Date = "" + Notes = $Notes + IssueUrl = $IssueUrl + Template = "meetingmini" + NoOpen = $NoOpen + Force = $Force + RootPath = $RootPath + AddNoteFolder = $false + DateToday = $true } -} Export-ModuleMember -Function New-NoteTodayClient -Alias cnote + $ret = New-Note @params -function New-NoteTodayMeeting{ + return $ret + +} Export-ModuleMember -Function New-NoteMeetingNext -Alias mnoten + +function New-NoteQuestion{ [CmdletBinding()] - [alias("mnote")] + [alias("qnote")] param( [Parameter(Mandatory,Position = 0)][string] $Name, - [Parameter(Mandatory,Position = 1)][string] $Title, + [Parameter(Position = 1)][string] $Title, [Parameter(Position = 2)][string] $Notes, [Parameter(ValueFromPipeline)][string] $IssueUrl, [Parameter()][switch] $NoOpen, @@ -320,28 +290,56 @@ function New-NoteTodayMeeting{ [Parameter()][string] $RootPath ) - begin { - $category = "meetings" - $section = $Name + $params = @{ + Category = "meetings" + Section = $Name + Title = [string]::IsNullOrWhiteSpace($Title) ? "Question" : "Question - $Title" + Date = "" + Notes = $Notes + IssueUrl = $IssueUrl + Template = "meetingmini" + NoOpen = $NoOpen + Force = $Force + RootPath = $RootPath + AddNoteFolder = $false + DateToday = $true } - process{ + $ret = New-Note @params - $folder = Get-NoteFolder -RootPath $RootPath -Category $category -Section $section -Force:$Force + return $ret - if (-not $folder) { - Write-Error "Client folder for '$section' does not exist and Force was not specified." - return - } +} Export-ModuleMember -Function New-NoteQuestion -Alias qnote - New-NoteToday ` - -Category $category ` - -Section $section ` - -Title $Title ` - -Notes $Notes ` - -IssueUrl $IssueUrl ` - -Template "meetingmini" ` - -NoOpen:$NoOpen +function New-NoteTemp{ + [CmdletBinding()] + [alias("tnote")] + param( + [Parameter(Position = 0)][string] $Name, + [Parameter(Position = 1)][string] $Title, + [Parameter(Position = 2)][string] $Notes, + [Parameter(ValueFromPipeline)][string] $IssueUrl, + [Parameter()][switch] $NoOpen, + [Parameter()][switch] $Force, + [Parameter()][string] $RootPath + ) + + $params = @{ + Category = "temp" + Section = $Name + Title = [string]::IsNullOrWhiteSpace($Title) ? "Notes" : "$Title" + Date = "" + Notes = $Notes + IssueUrl = $IssueUrl + Template = "none" + NoOpen = $NoOpen + Force = $Force + RootPath = $RootPath + AddNoteFolder = $false + DateToday = $true } -} Export-ModuleMember -Function New-NoteTodayMeeting -Alias mnote \ No newline at end of file + $ret = New-Note @params + + return $ret +} Export-ModuleMember -Function New-NoteTemp -Alias tnote \ No newline at end of file