Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions public/getNotes.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ function Get-Notes () {
[Alias("notes")]
param(
[Parameter()][string] $Filter,
[Parameter()][int32] $DaysAgo,
#all
[Parameter()][switch] $All
)

$DaysAgo = $DaysAgo -eq 0 ? 15 : $DaysAgo

$notes = GetNotes -Filter $filter

# Filter out files that are older than 30 days
$ret = $All ? $notes : ($notes | Where-Object { $_.LastWriteTime -gt (Get-Date).AddDays(-30) })
$ret = $All ? $notes : ($notes | Where-Object { $_.LastWriteTime -gt (Get-Date).AddDays(-$DaysAgo) })

# Create a custom object with required properties
$ret = $ret | ForEach-Object {
Expand Down Expand Up @@ -74,7 +77,8 @@ function GetNotesCategory {
)

process{
(($Path | Split-Path -Leaf) -split '-|\.')[1]
$ret = (($Path | Split-Path -Leaf) -split '-|\.')[1]
return $ret
}


Expand Down
5 changes: 5 additions & 0 deletions public/newNotes.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ function New-Note{
$Date = Get-Date -Format "yyMMdd"
}

if([string]::IsNullOrWhiteSpace($Date)) {
Write-Error "Date is empty. Consider using -DateToday or -Date to specify a date for the note."
return
}

$fileName = getFileName -Category $Category -Section $Section -Title $Title -Date $Date

# Create the note base folder
Expand Down
Loading