@@ -12,9 +12,10 @@ function New-Note{
1212 [Parameter ()][string ] $IssueUrl ,
1313 [Parameter ()][string ] [ValidateSet (" none" , " meetingmini" )] $Template = " none" ,
1414 [Parameter ()][switch ] $NoOpen ,
15- [Parameter ()][switch ] $AvoidChildFolder ,
15+ [Parameter ()][switch ] $AddNoteFolder ,
1616 [Parameter ()][switch ] $Force ,
17- [Parameter ()][string ] $RootPath
17+ [Parameter ()][string ] $RootPath ,
18+ [Parameter ()][switch ] $DateToday
1819
1920 )
2021
@@ -32,30 +33,35 @@ function New-Note{
3233 return
3334 }
3435
35- $fullTitle = getFullTitle - Category $Category - Section $Section - Title $Title - Date $Date
36+ # Replace date with today if specified
37+ if ($DateToday ) {
38+ $Date = Get-Date - Format " yyMMdd"
39+ }
40+
41+ $fileName = getFileName - Category $Category - Section $Section - Title $Title - Date $Date
3642
3743 # Create the note base folder
38- if ($AvoidChildFolder ){
39- # use folder as the parent folder of the note
40- $fullPath = Join-Path - Path $folder - ChildPath " $fullTitle .md"
41- } else {
44+ if ($AddNoteFolder ){
4245 # Create full path for the note file
43- $noteFolder = Join-Path - Path $folder - ChildPath $fullTitle
46+ $noteFolder = Join-Path - Path $folder - ChildPath $fileName
4447
4548 if (-not (Test-Path - Path $noteFolder )) {
4649 New-Item - Path $noteFolder - ItemType Directory - Force | Out-Null
4750 Write-Verbose " Created note folder: $noteFolder "
4851 }
49-
50- $fullPath = $noteFolder | Join-Path - ChildPath " $fullTitle .md"
52+
53+ $fullPath = $noteFolder | Join-Path - ChildPath " $fileName .md"
54+ } else {
55+ # use folder as the parent folder of the note
56+ $fullPath = Join-Path - Path $folder - ChildPath " $fileName .md"
5157 }
5258
5359 # Check if file already exists
5460 if (-Not (Test-Path - Path $fullPath )) {
5561
5662 $header = [string ]::IsNullOrWhiteSpace($Section ) ? $Category : $Section
5763
58- $content = getFileContent $Template $Title $header - Notes $Notes - IssueUrl $IssueUrl
64+ $content = getFileContent $Template $Title $header - Notes $Notes - IssueUrl $IssueUrl - Date $Date
5965
6066 # If $Force check that the folders of $fullPath exists and if not create it
6167 if ($Force ) {
@@ -81,7 +87,7 @@ function New-Note{
8187
8288} Export-ModuleMember - Function New-Note - Alias " note"
8389
84- function getFullTitle {
90+ function getFileName {
8591 [CmdletBinding ()]
8692 param (
8793 [Parameter (Mandatory )][string ] $Category ,
@@ -147,85 +153,120 @@ function New-NoteToday{
147153 [Parameter ()][string ] $RootPath
148154 )
149155
150- # FILENAME
151-
152- $folder = Get-NoteFolder - RootPath $RootPath - Category $Category - Section $Section - Force:$Force
153-
154- if (-Not $folder ) {
155- Write-Error " Failed to create the folder for the note. Try -Force."
156- return
157- }
158-
159- if (-Not (Test-Path - Path $folder )) {
160- Write-Error " Base folder for note does not exist '$folder '. Try -Force."
161- return
162- }
156+ $ret = New-Note `
157+ - Category $Category `
158+ - Section $Section `
159+ - Title $Title `
160+ - Notes $Notes `
161+ - IssueUrl $IssueUrl `
162+ - Template $Template `
163+ - NoOpen:$NoOpen `
164+ - AddNoteFolder:$AddNoteFolder `
165+ - Force:$Force `
166+ - RootPath $RootPath `
167+ - DateToday
168+
169+ return $ret
163170
164- # Extract just the folder name from the path
165- $today = Get-Date - Format " yyMMdd"
171+ } Export-ModuleMember - Function New-NoteToday - Alias " note"
166172
167- $header = [string ]::IsNullOrWhiteSpace($Section ) ? $Category : $Section
173+ # function New-NoteToday{
174+ # # Add Force parameter to support creation of client folder if it doesn't exist
175+ # [CmdletBinding()]
176+ # [alias("note")]
177+ # param(
178+ # [Parameter(Mandatory,Position = 0)][string] $Category,
179+ # [Parameter(Mandatory,Position = 1)][string] $Title,
180+ # [Parameter()][string] $Section,
181+ # [Parameter()][string] $Notes,
182+ # [Parameter()][string] $IssueUrl,
183+ # [Parameter()][string] [ValidateSet("none","meetingmini")] $Template = "none",
184+ # [Parameter()][switch] $NoOpen,
185+ # [Parameter()][switch] $AddNoteFolder,
186+ # [Parameter()][switch] $Force,
187+ # [Parameter()][string] $RootPath,
188+ # [Parameter()][string] $Date
189+ # )
190+
191+ # # FILENAME
192+
193+ # $folder = Get-NoteFolder -RootPath $RootPath -Category $Category -Section $Section -Force:$Force
194+
195+ # if(-Not $folder) {
196+ # Write-Error "Failed to create the folder for the note. Try -Force."
197+ # return
198+ # }
199+
200+ # if(-Not (Test-Path -Path $folder)) {
201+ # Write-Error "Base folder for note does not exist '$folder'. Try -Force."
202+ # return
203+ # }
204+
205+ # # Extract just the folder name from the path
206+ # $today = if([string]::IsNullOrWhiteSpace($Date)) { Get-Date -Format "yyMMdd" } else { $Date }
207+
208+ # $header = [string]::IsNullOrWhiteSpace($Section) ? $Category : $Section
168209
169- # Create FullTitle using folder name and title, replacing spaces with underscores
170- $fullTitle = " {0}-{1}-{2}" -f $today , $header , $Title
210+ # # Create FullTitle using folder name and title, replacing spaces with underscores
211+ # $fullTitle = "{0}-{1}-{2}" -f $today, $header, $Title
171212
172- # Normilize fullTitle by removing special characters and replacing spaces with underscores
173- $fullTitle = $fullTitle -replace ' \s+' , ' _'
213+ # # Normilize fullTitle by removing special characters and replacing spaces with underscores
214+ # $fullTitle = $fullTitle -replace '\s+', '_'
174215
175- # Create the note base folder
216+ # # Create the note base folder
176217
177- if ($AddNoteFolder ){
178- # Create full path for the note file
179- $noteFolder = Join-Path - Path $folder - ChildPath $fullTitle
218+ # if($AddNoteFolder){
219+ # # Create full path for the note file
220+ # $noteFolder = Join-Path -Path $folder -ChildPath $fullTitle
180221
181- if (-not (Test-Path - Path $noteFolder )) {
182- New-Item - Path $noteFolder - ItemType Directory - Force | Out-Null
183- Write-Verbose " Created note folder: $noteFolder "
184- }
185-
186- $fullPath = $noteFolder | Join-Path - ChildPath " $fullTitle .md"
187- } else {
188- # use folder as the parent folder of the note
189- $fullPath = Join-Path - Path $folder - ChildPath " $fullTitle .md"
190- }
191-
192- # Check if file already exists
193- if (-Not (Test-Path - Path $fullPath )) {
222+ # if (-not (Test-Path -Path $noteFolder)) {
223+ # New-Item -Path $noteFolder -ItemType Directory -Force | Out-Null
224+ # Write-Verbose "Created note folder: $noteFolder"
225+ # }
226+
227+ # $fullPath =$noteFolder | Join-Path -ChildPath "$fullTitle.md"
228+ # } else {
229+ # # use folder as the parent folder of the note
230+ # $fullPath = Join-Path -Path $folder -ChildPath "$fullTitle.md"
231+ # }
232+
233+ # # Check if file already exists
234+ # if (-Not (Test-Path -Path $fullPath)) {
194235
195- # Get template content
196- $content = Get-TemplatePath $Template | Get-FileContent
236+ # # Get template content
237+ # $content = Get-TemplatePath $Template | Get-FileContent
197238
198- # Replace placeholders in the template with actual values
199- $content = $content -replace ' {title}' , $Title
200- $content = $content -replace ' {header}' , $header
201- $content = $content -replace ' {date}' , $today
202- $content = $content -replace ' {notes}' , ([string ]::IsNullOrWhiteSpace($Notes ) ? ' -' : $Notes )
203- $content = $content -replace ' {issueurl}' , ([string ]::IsNullOrWhiteSpace($IssueUrl ) ? ' <IssueUrl>' : $IssueUrl )
204-
205-
206- # If $Force check that the folders of $fullPath exists and if not create it
207- if ($Force ) {
208- $parentFolder = Split-Path - Path $fullPath - Parent
209- if (-Not (Test-Path - Path $parentFolder )) {
210- New-Item - Path $parentFolder - ItemType Directory - Force | Out-Null
211- Write-Verbose " Created folder: $parentFolder "
212- }
213- }
214-
215- # Create the file with content
216- Set-Content - Path $fullPath - Value $content - Force
217- }
239+ # # Replace placeholders in the template with actual values
240+ # $content = $content -replace '{title}' , $Title
241+ # $content = $content -replace '{header}' , $header
242+ # $content = $content -replace '{date}' , $today
243+ # $content = $content -replace '{notes}' , ([string]::IsNullOrWhiteSpace($Notes) ? '-' : $Notes)
244+ # $content = $content -replace '{issueurl}' , ([string]::IsNullOrWhiteSpace($IssueUrl) ? '<IssueUrl>' : $IssueUrl)
245+
246+
247+ # # If $Force check that the folders of $fullPath exists and if not create it
248+ # if ($Force) {
249+ # $parentFolder = Split-Path -Path $fullPath -Parent
250+ # if (-Not (Test-Path -Path $parentFolder)) {
251+ # New-Item -Path $parentFolder -ItemType Directory -Force | Out-Null
252+ # Write-Verbose "Created folder: $parentFolder"
253+ # }
254+ # }
255+
256+ # # Create the file with content
257+ # Set-Content -Path $fullPath -Value $content -Force
258+ # }
218259
219- if ( -not $NoOpen ) {
220- # Open file in VS Code with cursor at the end
221- $gotocmd = " {0}{1}" -f $fullPath , " :9999"
222- code -- goto $gotocmd
223- }
260+ # if( -not $NoOpen) {
261+ # # Open file in VS Code with cursor at the end
262+ # $gotocmd = "{0}{1}" -f $fullPath, ":9999"
263+ # code --goto $gotocmd
264+ # }
224265
225- # Return file just created
226- return $fullPath
266+ # # Return file just created
267+ # return $fullPath
227268
228- } Export-ModuleMember - Function New-NoteToday - Alias " note"
269+ # } Export-ModuleMember -Function New-NoteToday -Alias "note"
229270
230271function New-NoteTodayClient {
231272 [CmdletBinding ()]
0 commit comments