Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

Commit

Permalink
v2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhitsolutions committed Oct 14, 2020
1 parent bac1916 commit 91ffcf7
Show file tree
Hide file tree
Showing 34 changed files with 748 additions and 802 deletions.
File renamed without changes.
145 changes: 145 additions & 0 deletions Archive/Show-MyTask.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@

#this command has been removed
Function Show-MyTask {

#colorize output using Write-Host
#this may not work in the PowerShell ISE

[cmdletbinding(DefaultParameterSetName = "Days")]
[OutputType("None")]
[Alias("shmt")]

Param(
[Parameter(ParameterSetName = "all")]
[switch]$All,
[Parameter(ParameterSetName = "Days")]
[int32]$DaysDue = 30
)

DynamicParam {
# Set the dynamic parameters' name
$ParameterName = 'Category'
# Create the dictionary
$RuntimeParameterDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary

# Create the collection of attributes
$AttributeCollection = New-Object System.Collections.ObjectModel.Collection[System.Attribute]

# Create and set the parameters' attributes
$ParameterAttribute = New-Object System.Management.Automation.ParameterAttribute
$ParameterAttribute.Mandatory = $false
$ParameterAttribute.ParameterSetName = "Category"
# Add the attributes to the attributes collection
$AttributeCollection.Add($ParameterAttribute)

# Generate and set the ValidateSet
if (Test-Path -Path $global:myTaskCategory) {
$arrSet = Get-Content -Path $global:myTaskCategory -Encoding Unicode |
Where-Object { $_ -match "\w+" } | ForEach-Object { $_.Trim() }
}
else {
$arrSet = $script:myTaskDefaultCategories
}
$ValidateSetAttribute = New-Object System.Management.Automation.ValidateSetAttribute($arrSet)

# Add the ValidateSet to the attributes collection
$AttributeCollection.Add($ValidateSetAttribute)

# Create and return the dynamic parameter
$RuntimeParameter = New-Object System.Management.Automation.RuntimeDefinedParameter($ParameterName, [string], $AttributeCollection)
$RuntimeParameterDictionary.Add($ParameterName, $RuntimeParameter)
return $RuntimeParameterDictionary
} #Dynamic Param

Begin {
$Category = $PsBoundParameters[$ParameterName]
Write-Verbose "[$((Get-Date).TimeofDay) BEGIN ] Starting $($MyInvocation.Mycommand)"

#display PSBoundparameters formatted nicely for Verbose output
[string]$pb = ($PSBoundParameters | Format-Table -AutoSize | Out-String).TrimEnd()
Write-Verbose "[$((Get-Date).TimeofDay) BEGIN ] PSBoundparameters: `n$($pb.split("`n").Foreach({"$("`t"*4)$_"}) | Out-String) `n"
}

Process {
#run Get-MyTask
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Getting Tasks"
$tasks = Get-MyTask @PSBoundParameters
if ($tasks.count -gt 0) {
#convert tasks to a text table
$table = ($tasks | Format-Table | Out-String -Stream).split("`r`n")

#define a regular expression pattern to match the due date
[regex]$rx = "\b\d{1,2}\/\d{1,2}\/(\d{2}|\d{4})\b"

#Write-Host "`n"
"`n"
"$([char]0x1b)[38;5;51m$($table[1])$([char]0x1b)[0m"
"$([char]0x1b)[38;5;51m$($table[2])$([char]0x1b)[0m"
#Write-Host $table[1] -ForegroundColor Cyan
#Write-Host $table[2] -ForegroundColor Cyan

#define a parameter hashtable to splat to Write-Host to better
#handle colors in the PowerShell ISE under Windows 10
$phash = @{
object = $Null
}
$table[3..$table.count] | ForEach-Object {

#add the incoming object as the object for Write-Host
$pHash.object = $_
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Analyzing $_ "
#test if DueDate is within 24 hours
if ($rx.IsMatch($_)) {
$hours = (($rx.Match($_).Value -as [datetime]) - (Get-Date)).totalhours
}

Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Hours = $hours"

#test if task is complete
if ($_ -match '\b100\b$') {
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Detected as completed"
$complete = $True
}
else {
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Detected as incomplete"
$complete = $False
}

#select a different color for overdue tasks
if ($complete) {
#display completed tasks in green
$phash.ForegroundColor = "$([char]0x1b)[92m" #"Green"
}
elseif ($_ -match "\bTrue\b") {
$phash.ForegroundColor = "$([char]0x1b)[91m" # "Red"
}
elseif ($hours -le 24 -AND (-Not $complete)) {
$phash.ForegroundColor = "$([char]0x1b)[38;5;208m" #"Yellow"
$hours = 999
}
elseif ($_ -match "^\s+") {
#use the existing color for tasks with wrapped descriptions
}
else {
if ($pHash.ContainsKey("ForegroundColor")) {
#remove foreground color so that Write-Host uses
#the current default
# $pHash.Remove("ForegroundColor")
$phash.ForeGroundColor = "$([char]0x1b)[37m"
}
}

# Write-Host @pHash
"{0}{1}{2}" -f $phash.ForegroundColor, $phash.object, "$([char]0x1b)[0m"

} #foreach
} #if tasks are found
else {
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] No tasks returned from Get-MyTask."
}
} #Process

End {
Write-Verbose "[$((Get-Date).TimeofDay) END ] Ending $($MyInvocation.Mycommand)"
} #End
} #Show-MyTask
6 changes: 3 additions & 3 deletions ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

<!-- copy the contents of $PSVersionTable -->

## What is the syntax or expression you are using?
## What is the syntax or expression you are using

<!-- copy command you are trying to run -->

## What happens?
## What happens

<!-- copy the results especially any error messages -->

## What do you think should happen?
## What do you think should happen

<!-- What are your expectations or assumptions -->
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2016-2019 JDH Information Technology Solutions, Inc.
Copyright (c) 2016-2020 JDH Information Technology Solutions, Inc.


Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
33 changes: 17 additions & 16 deletions MyTasks.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
RootModule = 'MyTasks.psm1'

# Version number of this module.
ModuleVersion = '2.3.0'
ModuleVersion = '2.4.0'

CompatiblePSEditions = @("Desktop", "Core")

Expand All @@ -22,7 +22,7 @@
CompanyName = 'JDH Information Technology Solutions, Inc.'

# Copyright statement for this module
Copyright = '(c) 2016-2019 JDH Information Technology Solutions, Inc. All rights reserved.'
Copyright = '(c) 2016-2020 JDH Information Technology Solutions, Inc. All rights reserved.'

# Description of the functionality provided by this module
Description = 'A tool set for managing tasks or to-do projects in PowerShell. Task data is stored in XML and managed through a PowerShell class.'
Expand Down Expand Up @@ -58,27 +58,28 @@
# TypesToProcess = @()

# Format files (.ps1xml) to be loaded when importing this module
FormatsToProcess = "MyTasks.format.ps1xml", "mytaskpath.format.ps1xml"
FormatsToProcess = "formats\MyTasks.format.ps1xml", "formats\mytaskpath.format.ps1xml"

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()

# Functions to export from this module

FunctionsToExport = if ($PSEdition -eq 'Desktop') {
FunctionsToExport = if ($PSEdition -eq 'Desktop') {

@("New-MyTask", "Set-MyTask", "Remove-MyTask", "Get-MyTask",
"Show-MyTask", "Complete-MyTask", "Get-MyTaskCategory", "Add-MyTaskCategory",
"Remove-MyTaskCategory", "Backup-MyTaskFile", "Save-MyTask", "Enable-EmailReminder",
"Disable-EmailReminder", "Get-EmailReminder", "Set-MyTaskHome", "Get-MyTaskArchive",
"Get-MyTaskHome")
@("New-MyTask", "Set-MyTask", "Remove-MyTask", "Get-MyTask",
"Complete-MyTask", "Get-MyTaskCategory", "Add-MyTaskCategory",
"Remove-MyTaskCategory", "Backup-MyTaskFile", "Save-MyTask", "Enable-EmailReminder",
"Disable-EmailReminder", "Get-EmailReminder", "Set-MyTaskHome", "Get-MyTaskArchive",
"Get-MyTaskHome")

} else {
}
else {
@("New-MyTask", "Set-MyTask", "Remove-MyTask", "Get-MyTask",
"Show-MyTask", "Complete-MyTask", "Get-MyTaskCategory", "Add-MyTaskCategory",
"Complete-MyTask", "Get-MyTaskCategory", "Add-MyTaskCategory",
"Remove-MyTaskCategory", "Backup-MyTaskFile", "Save-MyTask", "Set-MyTaskHome",
"Get-MyTaskArchive","Get-MyTaskHome")
}
"Get-MyTaskArchive", "Get-MyTaskHome")
}

# Cmdlets to export from this module
# CmdletsToExport = '*'
Expand All @@ -88,8 +89,8 @@
#'myTaskPath','myTaskDefaultCategories','myTaskArchivePath','mytaskhome','myTaskCategory'

# Aliases to export from this module
AliasesToExport = 'gmt', 'smt', 'shmt', 'rmt', 'cmt', 'nmt', 'Archive-MyTask', 'task',
'Get-MyTaskPath', 'Set-MyTaskPath'
AliasesToExport = 'gmt', 'smt', 'rmt', 'cmt', 'nmt', 'Archive-MyTask', 'task',
'Get-MyTaskPath', 'Set-MyTaskPath', 'shmt', "Show-MyTask"

# DSC resources to export from this module
# DscResourcesToExport = @()
Expand All @@ -106,7 +107,7 @@
PSData = @{

# Tags applied to this module. These help with module discovery in online galleries.
Tags = 'XML', 'ToDo', 'Projects', 'Tasks'
Tags = 'ToDo', 'projects', 'tasks', 'reminder'

# A URL to the license for this module.
LicenseUri = 'https://github.com/jdhitsolutions/MyTasks/blob/master/LICENSE.txt'
Expand Down
4 changes: 2 additions & 2 deletions MyTasks.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ $script:myTaskDefaultCategories = "Work", "Personal", "Other", "Customer"
#endregion

#dot source functions
. $psscriptroot\MyTasksFunctions.ps1
. $psscriptroot\functions\MyTasksFunctions.ps1
if ($psedition -eq 'Desktop') {
. $psscriptroot\emailfunctions.ps1
. $psscriptroot\functions\emailfunctions.ps1
}

$cmd = "Get-MyTask", "Set-MyTask", "Complete-MyTask", "Remove-MyTask"
Expand Down
Loading

0 comments on commit 91ffcf7

Please sign in to comment.