Skip to content

Commit

Permalink
v1.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhitsolutions committed May 28, 2024
1 parent 576a5e3 commit 539758b
Show file tree
Hide file tree
Showing 7 changed files with 367 additions and 26 deletions.
2 changes: 1 addition & 1 deletion PSWorkItem.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

@{
RootModule = 'PSWorkItem.psm1'
ModuleVersion = '1.9.0'
ModuleVersion = '1.10.0'
CompatiblePSEditions = 'Core'
GUID = '4d3ff215-69ea-4fe6-8ad6-97ffc3a15bfb'
Author = 'Jeff Hicks'
Expand Down
40 changes: 27 additions & 13 deletions PSWorkItem.psm1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# used for culture debugging
# write-host "Importing with culture $(Get-Culture)"

if ((Get-Culture).Name -match "\w+") {
if ((Get-Culture).Name -match '\w+') {
Import-LocalizedData -BindingVariable strings
}
else {
Expand All @@ -10,7 +10,7 @@ else {
}

#Adding a failsafe check for Windows PowerShell
if ($IsMacOS -or ($PSEdition -eq "Desktop")) {
if ($IsMacOS -or ($PSEdition -eq 'Desktop')) {
Write-Warning $Strings.Unsupported
#bail out
Return
Expand All @@ -29,12 +29,12 @@ ForEach-Object {
#there may be version conflicts

#required versions
[version]$NStackVersion = "1.0.7"
[version]$TerminalGuiVersion = "1.14.0"
[version]$NStackVersion = '1.1.1.0'
[version]$TerminalGuiVersion = '1.16.0'

$dlls = "$PSScriptRoot\assemblies\NStack.dll","$PSScriptRoot\assemblies\Terminal.Gui.dll"
$dlls = "$PSScriptRoot\assemblies\NStack.dll", "$PSScriptRoot\assemblies\Terminal.Gui.dll"
foreach ($dll in $dlls) {
$name = Split-Path -path $dll -leaf
$name = Split-Path -Path $dll -Leaf
#write-host "Loading $dll" -fore yellow
Try {
Add-Type -Path $dll -ErrorAction Stop
Expand All @@ -45,17 +45,17 @@ foreach ($dll in $dlls) {

#$verMessage = "Detected version $($PSStyle.Foreground.Red){0}$($PSStyle.Reset) which is less than the expected version of $($PSStyle.Foreground.Green){1}$($PSStyle.Reset). $($PSStyle.Italic)There may be unexpected behavior$($PSStyle.Reset). You may need to start a new PowerShell session and load this module first."
Switch ($Name) {
"NStack.dll" {
'NStack.dll' {
#get currently loaded version
$ver = [System.Reflection.Assembly]::GetAssembly([NStack.uString]).GetName().version
if ($ver -lt $NStackVersion) {
$Detail = $strings.WarnDetected -f $ver,$NStackVersion,$PSStyle.Foreground.Red,$PSStyle.Foreground.Green,$PSStyle.Italic,$PSStyle.Reset
$Detail = $strings.WarnDetected -f $ver, $NStackVersion, $PSStyle.Foreground.Red, $PSStyle.Foreground.Green, $PSStyle.Italic, $PSStyle.Reset
}
}
"Terminal.Gui.dll" {
'Terminal.Gui.dll' {
$ver = [System.Reflection.Assembly]::GetAssembly([Terminal.Gui.Application]).GetName().version
if ($ver -lt $TerminalGuiVersion) {
$Detail = $strings.WarnDetected -f $ver,$TerminalGuiVersion,$PSStyle.Foreground.Red,$PSStyle.Foreground.Green,$PSStyle.Italic,$PSStyle.Reset
$Detail = $strings.WarnDetected -f $ver, $TerminalGuiVersion, $PSStyle.Foreground.Red, $PSStyle.Foreground.Green, $PSStyle.Italic, $PSStyle.Reset
}
}
} #switch
Expand Down Expand Up @@ -133,7 +133,7 @@ class PSWorkItemDatabase {
#region type extensions

Update-TypeData -TypeName PSWorkItemCategory -MemberType ScriptProperty -MemberName ANSIString -Value { $PSWorkItemCategory[$this.Category] -replace "`e",
"``e" } -force
"``e" } -Force
#endregion

#region settings and configuration
Expand All @@ -160,7 +160,7 @@ If (Test-Path $PreferencePath) {
$global:PSWorkItemDefaultDays = $importPref.DefaultDays
}
If ($importPref.DefaultCategory) {
$global:PSDefaultParameterValues["New-PSWorkItem:Category"] = $importPref.DefaultCategory
$global:PSDefaultParameterValues['New-PSWorkItem:Category'] = $importPref.DefaultCategory
}
}
else {
Expand All @@ -169,4 +169,18 @@ else {
$global:PSWorkItemDefaultDays = 30
}

#endregion
#endregion

#region auto completers

Register-ArgumentCompleter -CommandName Set-PSWorkItem,Remove-PSWorkItem,Complete-PSWorkItem -ParameterName ID -ScriptBlock {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)

Invoke-MySQLiteQuery "Select Name,ID,Completed from Tasks" -database $PSWorkItemPath |
ForEach-Object {
[System.Management.Automation.CompletionResult]::new([int]$_.ID, [int]$_.ID, 'ParameterValue', $_.Name)
}
}

#endregion

Loading

0 comments on commit 539758b

Please sign in to comment.