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

Commit

Permalink
v1.5.1
Browse files Browse the repository at this point in the history
fixed bug with myTaskCategory (Issue #27)
updated About help
  • Loading branch information
jdhitsolutions committed Jun 18, 2018
1 parent f3452c4 commit d6b14ac
Show file tree
Hide file tree
Showing 8 changed files with 206 additions and 123 deletions.
Binary file modified MyTasks.psd1
Binary file not shown.
12 changes: 6 additions & 6 deletions MyTasks.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@

#path to user defined categories
if ($isLinux) {
$mytaskhome = $home
$global:mytaskhome = $home
}
else {
$mytaskhome = "$home\Documents"
$global:mytaskhome = "$home\Documents"
}

#path to the category file
$myTaskCategory = Join-Path -Path $mytaskhome -ChildPath myTaskCategory.txt
$global:myTaskCategory = Join-Path -Path $mytaskhome -ChildPath myTaskCategory.txt

#path to stored tasks
$mytaskPath = Join-Path -Path $mytaskhome -ChildPath myTasks.xml
$global:mytaskPath = Join-Path -Path $mytaskhome -ChildPath myTasks.xml

#path to archived or completed tasks
$myTaskArchivePath = Join-Path -Path $mytaskhome -ChildPath myTasksArchive.xml
$global:myTaskArchivePath = Join-Path -Path $mytaskhome -ChildPath myTasksArchive.xml

#default task categories
$myTaskDefaultCategories = "Work","Personal","Other","Customer"
Expand All @@ -40,7 +40,7 @@ $aliases+= Set-Alias -Name Archive-MyTask -Value Save-MyTask -PassThru

#define a hashtable of parameters to splat to Export-ModuleMember
$exportParams = @{
Variable = "myTaskPath","myTaskDefaultCategories","myTaskArchivePath","mytaskhome"
#Variable = "myTaskPath","myTaskDefaultCategories","myTaskArchivePath","mytaskhome"
Function = "New-MyTask","Set-MyTask","Remove-MyTask","Get-MyTask",
"Show-MyTask","Complete-MyTask","Get-MyTaskCategory","Add-MyTaskCategory",
"Remove-MyTaskCategory","Backup-MyTaskFile","Save-MyTask","Enable-EmailReminder",
Expand Down
47 changes: 26 additions & 21 deletions MyTasksFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,9 @@ Function New-MyTask {
$AttributeCollection.Add($ParameterAttribute)

# Generate and set the ValidateSet
if (Test-Path -Path $myTaskCategory) {
$arrSet = Get-Content -Path $myTaskCategory | where-object {$_ -match "\w+"} | foreach-object {$_.Trim()}
if (Test-Path -Path $global:myTaskCategory) {
$arrSet = Get-Content -Path $global:myTaskCategory |
where-object {$_ -match "\w+"} | foreach-object {$_.Trim()}
}
else {
$arrSet = $myTaskDefaultCategories
Expand Down Expand Up @@ -322,8 +323,8 @@ Function Set-MyTask {
$AttributeCollection.Add($ParameterAttribute)

# Generate and set the ValidateSet
if (Test-Path -Path $myTaskCategory) {
$arrSet = Get-Content -Path $myTaskCategory -Encoding Unicode | where-object {$_ -match "\w+"} | foreach-object {$_.Trim()}
if (Test-Path -Path $global:myTaskCategory) {
$arrSet = Get-Content -Path $global:myTaskCategory -Encoding Unicode | where-object {$_ -match "\w+"} | foreach-object {$_.Trim()}
}
else {
$arrSet = $myTaskDefaultCategories
Expand Down Expand Up @@ -560,8 +561,8 @@ Function Get-MyTask {
$AttributeCollection.Add($ParameterAttribute)

# Generate and set the ValidateSet
if (Test-Path -Path $myTaskCategory) {
$arrSet = Get-Content -Path $myTaskCategory | where-object {$_ -match "\w+"} | foreach-object {$_.Trim()}
if (Test-Path -Path $global:myTaskCategory) {
$arrSet = Get-Content -Path $global:myTaskCategory | where-object {$_ -match "\w+"} | foreach-object {$_.Trim()}
}
else {
$arrSet = $myTaskDefaultCategories
Expand Down Expand Up @@ -686,8 +687,8 @@ Function Show-MyTask {
$AttributeCollection.Add($ParameterAttribute)

# Generate and set the ValidateSet
if (Test-Path -Path $myTaskCategory) {
$arrSet = Get-Content -Path $myTaskCategory -Encoding Unicode |
if (Test-Path -Path $global:myTaskCategory) {
$arrSet = Get-Content -Path $global:myTaskCategory -Encoding Unicode |
where-object {$_ -match "\w+"} | foreach-object {$_.Trim()}
}
else {
Expand Down Expand Up @@ -924,9 +925,9 @@ Function Get-MyTaskCategory {

} #begin
Process {
If (Test-Path -Path $myTaskCategory) {
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Retrieving user categories from $myTaskCategory"
Get-Content -Path $myTaskCategory -Encoding Unicode | Where-object {$_ -match "\w+"}
If (Test-Path -Path $global:myTaskCategory) {
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Retrieving user categories from $global:myTaskCategory"
Get-Content -Path $global:myTaskCategory -Encoding Unicode | Where-object {$_ -match "\w+"}
}
else {
#Display the defaults
Expand Down Expand Up @@ -957,12 +958,12 @@ Function Add-MyTaskCategory {
Write-Verbose "[$((Get-Date).TimeofDay) BEGIN ] Starting: $($MyInvocation.Mycommand)"
#test if user category file already exists and if not, then
#create it
if (-Not (Test-Path -Path $myTaskCategory)) {
Write-Verbose "[$((Get-Date).TimeofDay) BEGIN ] Creating new user category file $myTaskCategory"
Set-Content -Value "" -Path $myTaskCategory -Encoding Unicode
if (-Not (Test-Path -Path $global:myTaskCategory)) {
Write-Verbose "[$((Get-Date).TimeofDay) BEGIN ] Creating new user category file $global:myTaskCategory"
Set-Content -Value "" -Path $global:myTaskCategory -Encoding Unicode
}
#get current contents
$current = Get-Content -Path $myTaskCategory -Encoding Unicode | where-object {$_ -match "\w+"}
$current = Get-Content -Path $global:myTaskCategory -Encoding Unicode | where-object {$_ -match "\w+"}
} #begin

Process {
Expand All @@ -972,7 +973,7 @@ Function Add-MyTaskCategory {
}
else {
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Adding $item"
Add-Content -Value $item.Trim() -Path $myTaskCategory -Encoding Unicode
Add-Content -Value $item.Trim() -Path $global:myTaskCategory -Encoding Unicode
}
}
} #process
Expand Down Expand Up @@ -1000,11 +1001,11 @@ Function Remove-MyTaskCategory {
Write-Verbose "[$((Get-Date).TimeofDay) BEGIN ] Starting: $($MyInvocation.Mycommand)"

#get current contents
$current = Get-Content -Path $myTaskCategory -Encoding Unicode| where-object {$_ -match "\w+"}
$current = Get-Content -Path $global:myTaskCategory -Encoding Unicode| where-object {$_ -match "\w+"}
#create backup
$back = Join-Path -path $mytaskhome -ChildPath MyTaskCategory.bak
Write-Verbose "[$((Get-Date).TimeofDay) BEGIN ] Creating backup copy"
Copy-Item -Path $myTaskCategory -Destination $back -Force
Copy-Item -Path $global:myTaskCategory -Destination $back -Force
} #begin

Process {
Expand All @@ -1017,8 +1018,8 @@ Function Remove-MyTaskCategory {

End {
#update file
Write-Verbose "[$((Get-Date).TimeofDay) END ] Updating: $myTaskCategory"
Set-Content -Value $current -Path $myTaskCategory -Encoding Unicode
Write-Verbose "[$((Get-Date).TimeofDay) END ] Updating: $global:myTaskCategory"
Set-Content -Value $current -Path $global:myTaskCategory -Encoding Unicode
Write-Verbose "[$((Get-Date).TimeofDay) END ] Ending: $($MyInvocation.Mycommand)"
} #end
}
Expand Down Expand Up @@ -1424,7 +1425,8 @@ Function Set-MyTaskPath {
Param(
[Parameter(Mandatory, HelpMessage = "Enter the path to your new myTaskPath directory")]
[ValidateScript( {Test-Path $_})]
[string]$Path
[string]$Path,
[switch]$Passthru
)

If ($pscmdlet.ShouldProcess("$path", "Update task path")) {
Expand All @@ -1439,6 +1441,9 @@ Function Set-MyTaskPath {
#path to archived or completed tasks
$global:myTaskArchivePath = Join-Path -Path $mytaskhome -ChildPath myTasksArchive.xml

if ($passthru) {
Get-Variable myTaskHome,myTaskPath,myTaskArchivePath,myTaskCategory
}
}
} #close Set-MyTaskPath

Expand Down
41 changes: 28 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# MyTasks
# 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.

Expand All @@ -7,74 +7,89 @@ This PowerShell module is designed as a task or simple To-Do manager. The module
Task data is stored in an XML file in the user's Documents folder. Here are a few highlights.

## Class based

This module requires at least PowerShell version 5.0 since is uses a class definition for the task object. While you could use the object's properties and methods directly, you should use the appropriate module command.

## XML Data

All of the task information is stored in an XML file. The commands in this module will read in, update, and remove items as needed using PowerShell commands such as `Select-XML`.

## Categories

The Task object includes a Category property. The module will define a default set of categories, but users can create their own by using the MyTaskCategory commands:

+ Add-MyTaskCategory
+ Get-MyTaskCategory
+ Remove-MyTaskCategory

## Basic Usage

You create a task with at least a name and category. The default due date will be 7 days from the current date and time.
```

```powershell
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
```

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

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

Because the task has a Progress property, you can use `Set-MyTask` to update that as well.
```

```powershell
Set-Mytask "book review" -Progress 60
```

To view tasks you can use `Get-MyTask`. Normally, you will use `Get-MyTask` to display tasks, all, some or a single item:

```
```powershell
PS S:\> get-mytask -name MemoryTools
ID Name Description DueDate OverDue Category Progress
-- ---- ----------- ------- ------- -------- --------
8 MemoryTools update module 7/22/2018 False Projects 10
```

The default behavior is to display incomplete tasks due in the next 30 days. Look at the help for [Get-MyTask](.\docs\Get-MyTask.md) for more information.

There is also a command called `Show-MyTask` which is really nothing more than a wrapper to `Get-MyTask`. The "Show" command will write output directly to the host. Incomplete tasks that are overdue will be displayed in red text. Tasks that will be due in 24 hours will be displayed in yellow. If you select all tasks then completed items will be displayed in green. This command may not work in the PowerShell ISE.


![](./images/show-mytask-1.png)

When a task is finished you can mark it as complete.
```

```powershell
Complete-MyTask -name "order coffee"
```
The task will remain but be marked as 100% complete. You can still see the task when using the -All parameter with `Get-MyTask` or `Show-MyTask`. At some point you might want to remove completed tasks from the master XML file. You can use `Remove-MyTask` to permanently delete them. Or use the `Archive-MyTask` command to move them to an archive xml file.

The task will remain but be marked as 100% complete. You can still see the task when using the -All parameter with `Get-MyTask` or `Show-MyTask`. At some point you might want to remove completed tasks from the master XML file. You can use `Remove-MyTask` to permanently delete them. Or use the `Archive-MyTask` command to move them to an archive xml file.

## Format Views

The module includes a format.ps1xml file that defines a default display when you run `Get-MyTask`. You will get a slightly different set of properties when you run `Get-MyTask | Format-List`. There is also a custom table view called Category which will create a table grouped by the Category property. You should sort the tasks first: `Get-MyTask | Sort-Object Category | Format-Table -view category`.

![](./images/show-mytask-2.png)

## Archiving and Removing ##
## Archiving and Removing

Over time your task file might get quite large. Even though the default behavior is to ignore completed tasks, you have an option to archive them to a separate XML file using `Save-MyTask` which has an alias of `Archive-MyTask`:

```
```powershell
Get-Mytask -Completed | Archive-MyTask
```

There is an option to archive tasks when you run `Complete-MyTask`. There are no commands in this module for working with the archived XML file at this time. Or you can completely delete a task with `Remove-MyTask`.

## Email Reminders

If you are running this module on a Windows platform that includes the PSScheduledJob module, you can create a scheduled PowerShell job that will send you a daily email with tasks that are due in 3 days or less. The default is a plain text message but you can also send it as HTML. Use the `Enable-EmailReminder` command to set up the job.

You should read full help and examples for all commands as well as the [about_MyTasks](./docs/about_MyTasks.md) help file.
Expand All @@ -95,7 +110,7 @@ You should read full help and examples for all commands as well as the [about_My
- [Get-EmailReminder](./docs/Get-EmailReminder.md)

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

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

*last updated 5 February 2018*
*last updated 18 June 2018*
2 changes: 1 addition & 1 deletion Tests/MyTasks.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ $theModule = get-module -name mytasks

It "Should export 4 variables by default" {
$theModule.ExportedVariables.Count | Should be 4
}
} -skip

It "Should have a formatting xml file" {
$theModule.ExportedFormatFiles.Count | Should be 1
Expand Down
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Changelog for MyTasks

v1.5.1
fixed bug with myTaskCategory (Issue #27)
updated About help

v1.5.0
Added a patch to store date in an ISO friendly format. (Issue #23 and Issue #22)
Added a new function, Set-MyTaskPath to allow you to update the task folder (Issue #20)
Expand Down
Loading

0 comments on commit d6b14ac

Please sign in to comment.