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

Commit

Permalink
see changelog for v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhitsolutions committed Feb 20, 2019
1 parent f46435f commit 7fd53d3
Show file tree
Hide file tree
Showing 11 changed files with 247 additions and 37 deletions.
11 changes: 7 additions & 4 deletions MyTasks.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
RootModule = 'MyTasks.psm1'

# Version number of this module.
ModuleVersion = '1.9.0'
ModuleVersion = '2.0.0'

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

# ID used to uniquely identify this module
GUID = '6a5db6e0-9669-4178-a176-54b4931aa4e2'
Expand All @@ -26,7 +28,7 @@ Copyright = '(c) 2016-2019 JDH Information Technology Solutions, Inc. All rights
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.'

# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '5.0'
PowerShellVersion = '5.1'

# Name of the Windows PowerShell host required by this module
# PowerShellHostName = ''
Expand Down Expand Up @@ -56,7 +58,7 @@ PowerShellVersion = '5.0'
# TypesToProcess = @()

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

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()
Expand All @@ -65,7 +67,8 @@ FormatsToProcess = "MyTasks.format.ps1xml"
FunctionsToExport = @("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-MyTaskPath","Get-MyTaskArchive")
"Disable-EmailReminder","Get-EmailReminder","Set-MyTaskPath","Get-MyTaskArchive",
"Get-MyTaskPath")

# Cmdlets to export from this module
# CmdletsToExport = '*'
Expand Down
9 changes: 2 additions & 7 deletions MyTasks.psm1
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@

#region variables

#path to user defined categories
if ($isLinux) {
$global:mytaskhome = $home
}
else {
$global:mytaskhome = "$home\Documents"
}
#set default location that should work cross platform
$global:myTaskHome = [Environment]::GetFolderPath([Environment+SpecialFolder]::MyDocuments)

#path to the category file
$global:myTaskCategory = Join-Path -Path $mytaskhome -ChildPath myTaskCategory.txt
Expand Down
44 changes: 31 additions & 13 deletions MyTasksFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Class MyTask {
$this.Refresh()
}
#used for importing from XML
MyTask([string]$Name, [datetime]$DueDate, [string]$Description, [string]$Category,[boolean]$Completed) {
MyTask([string]$Name, [datetime]$DueDate, [string]$Description, [string]$Category, [boolean]$Completed) {
write-verbose "[CLASS ] Constructing with due date, description and category"
$this.Name = $Name
$this.DueDate = $DueDate
Expand Down Expand Up @@ -96,7 +96,7 @@ Function _ImportTasks {
}
$propHash | Out-String | Write-Verbose
Try {
$tmp = New-Object -TypeName MyTask -ArgumentList $propHash.Name, $propHash.DueDate, $propHash.Description, $propHash.Category,$propHash.completed
$tmp = New-Object -TypeName MyTask -ArgumentList $propHash.Name, $propHash.DueDate, $propHash.Description, $propHash.Category, $propHash.completed

#set additional properties
$tmp.TaskID = $prophash.TaskID
Expand Down Expand Up @@ -204,7 +204,7 @@ Function New-MyTask {
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Calculating due date in $Days days"
$DueDate = (Get-Date).AddDays($Days)
}
$task = New-Object -TypeName MyTask -ArgumentList $Name, $DueDate, $Description, $Category,$False
$task = New-Object -TypeName MyTask -ArgumentList $Name, $DueDate, $Description, $Category, $False

#convert to xml
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Converting to XML"
Expand Down Expand Up @@ -545,7 +545,7 @@ Function Get-MyTask {
[cmdletbinding(DefaultParameterSetName = "Days")]
[OutputType("MyTask")]
[Alias("gmt")]

Param(
[Parameter(
Position = 0,
Expand Down Expand Up @@ -746,7 +746,7 @@ Function Show-MyTask {
$table = ($tasks | Format-Table -AutoSize | 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{4}\b"
[regex]$rx = "\b\d{1,2}\/\d{1,2}\/(\d{2}|\d{4})\b"

Write-Host "`n"
Write-Host $table[1] -ForegroundColor Cyan
Expand All @@ -755,7 +755,7 @@ Function Show-MyTask {
#define a parameter hashtable to splat to Write-Host to better
#handle colors in the PowerShell ISE under Windows 10
$phash = @{
Object = $Null
object = $Null
}
$table[3..$table.count] | foreach-object {

Expand All @@ -767,6 +767,8 @@ Function Show-MyTask {
$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"
Expand All @@ -790,12 +792,13 @@ Function Show-MyTask {
$hours = 999
}
else {
if ($pHash.ContainsKey("foregroundcolor")) {
if ($pHash.ContainsKey("ForegroundColor")) {
#remove foreground color so that Write-Host uses
#the current default
$pHash.Remove("foregroundcolor")
$pHash.Remove("ForegroundColor")
}
}

Write-Host @pHash

} #foreach
Expand Down Expand Up @@ -1182,7 +1185,7 @@ Function Save-MyTask {
foreach ($node in $completed.node) {
$imp = $out.ImportNode($node.ParentNode, $True)
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Archiving $($node.parentnode.property[0].'#text')"
if ($PSCmdlet.ShouldProcess( $($node.parentnode.property[0].'#text') ,"Archiving")) {
if ($PSCmdlet.ShouldProcess( $($node.parentnode.property[0].'#text') , "Archiving")) {
$parent.AppendChild($imp) | Out-Null
#remove from existing file
$in.objects.RemoveChild($node.parentnode) | Out-Null
Expand Down Expand Up @@ -1241,7 +1244,7 @@ Function Enable-EmailReminder {
[Parameter(HelpMessage = "Send an HTML body email")]
[switch]$AsHtml,
[ValidateNotNullOrEmpty()]
[ValidateScript({$_ -gt 0})]
[ValidateScript( {$_ -gt 0})]
[int]$Days = 3,
[Parameter(Mandatory, HelpMessage = "Re-enter your local user credentials for the scheduled job task")]
[ValidateNotNullOrEmpty()]
Expand Down Expand Up @@ -1517,6 +1520,19 @@ Function Set-MyTaskPath {
}
} #close Set-MyTaskPath

Function Get-MyTaskPath {
[cmdletbinding()]
Param()

[PSCustomObject]@{
PSTypeName = "myTaskPath"
myTaskHome = $global:mytaskhome
myTaskPath = $global:myTaskPath
myTaskArchivePath = $global:myTaskArchivePath
myTaskCategory = $global:myTaskCategory
}
}


Function Get-MyTaskArchive {
[cmdletbinding(DefaultParameterSetName = "Name")]
Expand Down Expand Up @@ -1606,16 +1622,16 @@ Function Get-MyTaskArchive {

"Category" {
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Retrieving tasks for category $Category"
$results = $tasks.Where({$_.Category -eq $Category})
$results = $tasks.Where( {$_.Category -eq $Category})
} #category

} #switch

#display tasks if found otherwise display a warning
if ($results.count -ge 1) {
$results.foreach( {
$_.psobject.typenames.insert(0, "myTaskArchive")})
$results
$_.psobject.typenames.insert(0, "myTaskArchive")})
$results
}
else {
Write-Warning "No tasks found matching your criteria"
Expand All @@ -1628,5 +1644,7 @@ Function Get-MyTaskArchive {

} #Get-MyTask



#endregion

13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MyTasks

This PowerShell module is designed as a task or simple To-Do manager. The module contains several commands for working with tasks. It should work with both Windows PowerShell and PowerShell Core. You can install the latest version from the PowerShell Gallery. You will need the -Scope parameter for PowerShell Core.
This PowerShell module is designed as a task or simple To-Do manager. The module contains several commands for working with tasks. It should work with both Windows PowerShell and PowerShell Core with a few limitations. You can install the latest version from the PowerShell Gallery. You will need the -Scope parameter for PowerShell Core.

```powershell
Install-Module MyTasks [-scope currentuser]
Expand Down Expand Up @@ -41,13 +41,13 @@ New-MyTask "return library books" -Category personal
You can also specify a due date.

```powershell
New-MyTask "Pluralsight" -duedate "2/1/2018" -description "renew subscription" -category other
New-MyTask "Pluralsight" -duedate "2/1/2019" -description "renew subscription" -category other
```

You can use `Set-MyTask` to modify a task.

```powershell
Get-MyTask Pluralsight | Set-Mytask -DueDate 3/1/2018
Get-MyTask Pluralsight | Set-Mytask -DueDate 3/1/2019
```

Because the task has a Progress property, you can use [Set-MyTask](./docs/Set-MyTask.md) to update that as well.
Expand All @@ -63,7 +63,7 @@ PS S:\> get-mytask -name MemoryTools
ID Name Description DueDate OverDue Category Progress
-- ---- ----------- ------- ------- -------- --------
8 MemoryTools update module 7/22/2018 False Projects 10
8 MemoryTools update module 7/22/2019 False Projects 10
```

The default behavior is to display incomplete tasks due in the next 30 days. Look at the help for `Get-MyTask` for more information.
Expand Down Expand Up @@ -94,7 +94,7 @@ Over time your task file might get quite large. Even though the default behavior
Get-Mytask -Completed | Archive-MyTask
```

There is an option to archive tasks when you run [Complete-MyTask](./docs/Complete-MyTask.md). T. Or you can completely delete a task with `Remove-MyTask`.
There is an option to archive tasks when you run [Complete-MyTask](./docs/Complete-MyTask.md). Or you can completely delete a task with `Remove-MyTask`.

Use the `Get-myTaskArchive` to view archived tasks.

Expand All @@ -119,10 +119,11 @@ You should read full help and examples for all commands as well as the [about_My
+ [Disable-EmailReminder](docs/Disable-EmailReminder.md)
+ [Get-EmailReminder](docs/Get-EmailReminder.md)
+ [Set-MyTaskPath](docs/Set-MyTaskPath.md)
+ [Get-MyTaskPath](docs/Get-MyTaskPath.md)
+ [Get-MyTaskArchive](docs/Get-MyTaskArchive.md)

## Limitations

Please post any issues, questions or feature requests in the [Issues](https://github.com/jdhitsolutions/MyTasks/issues) section.

*last updated 04 January 2019*
*last updated 20 February 2019*
17 changes: 11 additions & 6 deletions Tests/MyTasks.module.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Import-Module -Name "$PSScriptRoot\..\Mytasks.psd1" -Force
Describe 'MyTasks' {

$Module = Get-Module -Name MyTasks
It 'should have 15 functions' {
$Module.ExportedFunctions.count | Should -Be 16
It 'should have 17 functions' {
$Module.ExportedFunctions.count | Should -Be 17
}

It 'should have 8 aliases command' {
Expand All @@ -30,16 +30,16 @@ Describe 'MyTasks' {
param ($Variable)
{Get-Variable -Name $variable -Scope global} | Should -Not -Throw
}
It 'should have a formatting xml file' {
$Module.ExportedFormatFiles.Count | Should -Be 1
It 'should have 2 formatting xml files' {
$Module.ExportedFormatFiles.Count | Should -Be 2
}

It 'should have an about help topic' {
{Get-Help about_mytasks} | Should -Not -Throw
}

It 'requires PowerShell 5.0' {
$Module.PowerShellVersion | Should -Be '5.0'
It 'requires PowerShell 5.1' {
$Module.PowerShellVersion | Should -Be '5.1'
}
} #describe my module

Expand All @@ -62,6 +62,7 @@ Describe "Functions" {
@{Name = 'Backup-MyTaskFile'}
@{Name = 'Set-MyTaskPath'}
@{Name = 'Get-myTaskArchive'}
@{Name = 'Get-MyTaskPath'}
)

It "<Name> has external help defined with at least one example" -TestCases $cmds {
Expand Down Expand Up @@ -181,6 +182,10 @@ Describe "Functions" {
}

Context 'Get-MyTaskArchive' {

}

Context 'Get-MyTaskPath' {

}

Expand Down
11 changes: 10 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Change Log for MyTasks

## v2.0.0

+ Updated manifest to require PowerShell 5.1 and support for both Desktop and Core PSEditions *Breaking Change*
+ Added `Get-MyTaskPath` command (Issue #36)
+ Added a format.ps1xml file for `Get-MyTaskPath`
+ Modified code to determine home folder to use `[Environment]::GetFolderPath([Environment+SpecialFolder]::MyDocuments)` Thank you @kilasuit and @thecliguy (Issue #35) *Breaking Change*
+ Fixed bug in `Show-Mytask` where year is displayed in 2 digits instead of 4 on Linux platforms.
+ documentation updates

## v1.9.0

+ Updated autocompleter to get task names and enclose in quotes
Expand All @@ -10,7 +19,7 @@
+ Modified `MyTasks.format.ps1xml` to support myTaskArchive type
+ Updated help

## v1.8.2
## v1.8.2ex

+ Fixed bugs with email reminder. Typo in a parameter name.
+ Added parameter validation for `-Days` in `Enable-EmailReminder`
Expand Down
62 changes: 62 additions & 0 deletions docs/Get-MyTaskPath.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
external help file: MyTasks-help.xml
Module Name: Mytasks
online version:
schema: 2.0.0
---

# Get-MyTaskPath

## SYNOPSIS

Get current values of the myTask variables

## SYNTAX

```yaml
Get-MyTaskPath [<CommonParameters>]
```

## DESCRIPTION

The myTasks module relies on a number of global variables to keep track of the necessary files. While you can use Get-Variable to see the current value, this command simplifies the entire process.

## EXAMPLES

### Example 1

```powershell
PS C:\> get-mytaskpath
myTaskHome : C:\Users\Jeff\dropbox\mytasks
myTaskPath : C:\Users\Jeff\dropbox\mytasks\myTasks.xml
myTaskArchivePath : C:\Users\Jeff\dropbox\mytasks\myTasksArchive.xml
myTaskCategory : C:\Users\Jeff\dropbox\mytasks\myTaskCategory.txt
```

Display the current locations. You can modify them using Set-MyTaskPath.

## PARAMETERS

### CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

### None

## OUTPUTS

### myTaskPath

## NOTES

Learn more about PowerShell:
http://jdhitsolutions.com/blog/essential-powershell-resources/

## RELATED LINKS

[Set-MyTaskPath]()
Loading

0 comments on commit 7fd53d3

Please sign in to comment.