Skip to content

Commit

Permalink
see changelog for v1.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhitsolutions committed Jan 30, 2019
1 parent e2d6689 commit 0566c47
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 29 deletions.
6 changes: 3 additions & 3 deletions PSCalendar.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
RootModule = 'PSCalendar.psm1'

# Version number of this module.
ModuleVersion = '1.5.0'
ModuleVersion = '1.5.1'

# Supported PSEditions
# CompatiblePSEditions = @()
CompatiblePSEditions = @("Desktop","Core")

# ID used to uniquely identify this module
GUID = '222beda0-cdb5-464d-bf49-7ab701da86c9'
Expand All @@ -22,7 +22,7 @@ Author = 'Jeff Hicks'
CompanyName = 'JDH Information Technology Solutions, Inc.'

# Copyright statement for this module
Copyright = '(c) 2018 Jeff Hicks. All rights reserved.'
Copyright = '(c) 2018-19 Jeff Hicks. All rights reserved.'

# Description of the functionality provided by this module
Description = 'A PowerShell module to display a calendar in the console.'
Expand Down
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ This module contains a few functions for displaying a calendar in the PowerShell
You can install this module from the PowerShell Gallery.

```powershell
Install-Module PSCalendar
Install-Module PSCalendar [-scope currentuser]
```

It has been tested on PowerShell Core both under Windows and Linux and there is no reason these commands should not work.
It has been tested on PowerShell Core both under Windows and Linux and there is no reason these commands should not work, except for [Show-GuiCalendar](docs/Show-GuiCalendar.md).

## Get-Calendar
## [Get-Calendar](docs/Get-Calendar.md)

The commands in this module have been updated to take advantage of new features in Windows PowerShell. The main function, [Get-Calendar](), will display the current month in the console, highlighting the current date with asterisks.
The commands in this module have been updated to take advantage of new features in Windows PowerShell. The main function, [Get-Calendar](docs/Get-Calendar.md), will display the current month in the console, highlighting the current date with asterisks.

![get-calendar](assets/get-calendar.png)

Expand All @@ -31,7 +31,7 @@ The function should be culturally aware. The commands in this module that have a

There is a similar autocompletion for `-Year` that begins with the current year and then the next 5 years. Although nothing prevents you from entering any year you want.

## Show-Calendar
## [Show-Calendar](docs/Show-Calendar.md)

The module also contains a command to write a colorized version of the calendar to the console host. Whereas `Get-Calendar` writes a string to the pipeline, `Show-Calendar` writes directly to the host using `Write-Host`.

Expand All @@ -41,7 +41,9 @@ This command is in essence a "wrapper" function for `Get-Calendar`.

![show calendar with highlights](assets/show-calendar-2.png)

## Show-GUICalendar
*Note: Starting with version 1.5.1, the current day will be highlighted in Red, although you can modify that via the TodayColor parameter. I did not update the screen shots.*

## [Show-GUICalendar](docs/Show-GuiCalendar)

Finally, you can display a graphical calendar using a WPF-based script. The function runs the calendar-related code in a runspace so it does not block your prompt. You can display up to 3 months and specify dates to highlight.

Expand All @@ -51,6 +53,6 @@ PS C:\> Show-GuiCalendar 12/2018 2/2019 -highlight 12/24/18,12/25/18,12/31/18,1/

![show-guicalendar](assets/show-guicalendar.png)

The calendar form is transparent. But you should be able to click on it to drag it around your screen. You can also use the + and - keys to increase or decrease the calendar's opacity. Be aware that if you close the PowerShell session that launched the calendar, the calendar too will close.
The calendar form is transparent. But you should be able to click on it to drag it around your screen. You can also use the + and - keys to increase or decrease the calendar's opacity. Be aware that if you close the PowerShell session that launched the calendar, the calendar too will close. This function requires Windows PowerShell.

*last updated 10 January 2019*
*last updated 30 January 2019*
26 changes: 16 additions & 10 deletions calendar-functions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ Function Show-Calendar {
[cmdletbinding()]
[Alias("scal")]
Param(

[Parameter(Position = 1, ParameterSetName = "month")]
[ValidateNotNullorEmpty()]
[ValidateScript( {
Expand Down Expand Up @@ -196,6 +195,10 @@ Function Show-Calendar {
[Parameter(HelpMessage = "Specify a color for the days of the week heading.")]
[ValidateNotNullOrEmpty()]
[consolecolor]$DayColor = "Cyan",

[Parameter(HelpMessage = "Specify a color to mark today")]
[ValidateNotNullOrEmpty()]
[consolecolor]$TodayColor = "Red",
[System.Management.Automation.Host.Coordinates]$Position
)

Expand All @@ -216,7 +219,7 @@ Function Show-Calendar {
}

#remove color parameters if specified
"HighlightColor", "TitleColor", "DayColor" | foreach-object {
"HighlightColor", "TitleColor", "DayColor","TodayColor" | foreach-object {
if ($PSBoundParameters.Containskey($_)) {
$PSBoundParameters.Remove($_) | Out-Null
}
Expand All @@ -237,7 +240,7 @@ Function Show-Calendar {
if ($position) {
$host.ui.RawUI.CursorPosition = $Position
}
write-Host $line -ForegroundColor $TitleColor
Write-Host $line -ForegroundColor $TitleColor
}
elseif ($line -match "\w{3}|-{3}") {
#write the day names and underlines
Expand All @@ -254,25 +257,28 @@ Function Show-Calendar {
$Position.y++
$host.ui.RawUI.CursorPosition = $Position
}
$m.Matches($week).Value | foreach-object {
$m.Matches($week).Value | ForEach-Object {

$day = "$_"
if ($day -match "\*") {
write-host "$($day.replace('*','').padleft(3," ")) " -NoNewline -ForegroundColor $HighlightColor
if ($day -match "\*$((Get-Date).day)\*" ) {
Write-Host "$($day.replace('*','').padleft(3," ")) " -NoNewline -ForegroundColor $TodayColor
}
elseif ($day -match "\*") {
Write-Host "$($day.replace('*','').padleft(3," ")) " -NoNewline -ForegroundColor $HighlightColor
}
else {
write-host "$($day.PadLeft(3," ")) " -nonewline
Write-Host "$($day.PadLeft(3," ")) " -nonewline
}
}

write-host ""
Write-Host ""
}
else {
if ($Position) {
$Position.y++
$host.ui.RawUI.CursorPosition = $Position
}
Write-host $line
Write-Host $line
}
} #foreach line in calarray

Expand Down Expand Up @@ -472,7 +478,7 @@ Function Show-GuiCalendar {

$cal.add_DisplayDateChanged( {
# add the selected days for the currently displayed month
$cal | out-string | write-host
$cal | out-string | Write-Host
[datetime]$month = $cal.Displaydate
if ($highlightdate) {
foreach ($d in $HighlightDate) {
Expand Down
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log for PSCalendar

## v1.5.1

+ Modified `Show-Calendar` to use a different highlight color for today.
+ Updated help
+ Updated `README.md`

## v1.5.0

+ Modified `Show-Calendar` to allow you to specify a position in the console.
Expand Down
4 changes: 2 additions & 2 deletions docs/Get-Calendar.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Sun Mon Tue Wed Thu Fri Sat
30 1 2 3 4 5 6
```

how the current calendar and highlight today. The month name will be centered in your output.
Show the current calendar and highlight today. The month name will be centered in your output.

### EXAMPLE 2

Expand Down Expand Up @@ -102,7 +102,7 @@ Sun Mon Tue Wed Thu Fri Sat
30 31 1 2 3 4 5
```

Display a month and highlight a specific date.
Display a month and highlight a specific date.

## PARAMETERS

Expand Down
27 changes: 22 additions & 5 deletions docs/Show-Calendar.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ Display a colorized calendar month in the console.
## SYNTAX

```yaml

Show-Calendar [[-Month] <String>] [[-Year] <Int32>] [-HighlightDate <String[]>]
[-HighlightColor <ConsoleColor>] [-TitleColor <ConsoleColor>] [-DayColor <ConsoleColor>]
[-Position <Coordinates>] [<CommonParameters>]
[-TodayColor <ConsoleColor>] [-Position <Coordinates>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -127,7 +128,7 @@ Aliases:

Required: False
Position: Named
Default value: None
Default value: Cyan
Accept pipeline input: False
Accept wildcard characters: False
```
Expand Down Expand Up @@ -159,7 +160,23 @@ Aliases:

Required: False
Position: Named
Default value: None
Default value: Yellow
Accept pipeline input: False
Accept wildcard characters: False
```
### -TodayColor
Specify a color to mark today.
```yaml
Type: ConsoleColor
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: Red
Accept pipeline input: False
Accept wildcard characters: False
```
Expand All @@ -174,11 +191,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## OUTPUTS
### None. This command writes to the PowerShell hosting application.
### None
## NOTES
This command should have an alias of scal.
This command should have an alias of scal. It writes to the PowerShell hosting application not to the PowerShell pipeline.
Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/
Expand Down
2 changes: 1 addition & 1 deletion test/PSCalendar.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,4 @@ InModuleScope $moduleName {
} -tag command
}

Write-Host "You will need to manually kill and graphical calendars that were spawned from the test." -ForegroundColor yellow
Write-Host "You will need to manually kill any graphical calendars that were spawned from the test." -ForegroundColor yellow

0 comments on commit 0566c47

Please sign in to comment.