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

Commit

Permalink
v1.2.0
Browse files Browse the repository at this point in the history
Modified files to support PowerShell Core
Update help documentation
Updated README
Updated manifest
  • Loading branch information
jdhitsolutions committed Jan 3, 2018
1 parent 6abbafa commit b0a1c42
Show file tree
Hide file tree
Showing 20 changed files with 3,047 additions and 2,389 deletions.
Binary file modified MyTasks.psd1
Binary file not shown.
16 changes: 11 additions & 5 deletions MyTasks.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,27 @@
#region variables

#path to user defined categories
$myTaskCategory = Join-Path -Path $home\Documents\ -ChildPath myTaskCategory.txt
if ($isLinux) {
$mytaskhome = $home
}
else {
$mytaskhome = "$home\Documents"
}
$myTaskCategory = Join-Path -Path $mytaskhome -ChildPath myTaskCategory.txt

#path to stored tasks
$mytaskPath = Join-Path -Path "$home\Documents\" -ChildPath myTasks.xml
$mytaskPath = Join-Path -Path $mytaskhome -ChildPath myTasks.xml

#path to archived or completed tasks
$myTaskArchivePath = Join-Path -Path "$home\Documents\" -ChildPath myTasksArchive.xml
$myTaskArchivePath = Join-Path -Path $mytaskhome -ChildPath myTasksArchive.xml

#default task categories
$myTaskDefaultCategories = "Work","Personal","Other","Customer"

#endregion

#dot source functions
. $psscriptroot\myTasksFunctions.ps1
. $psscriptroot\MyTasksFunctions.ps1

#define some aliases
Set-Alias -Name gmt -Value Get-MyTask
Expand All @@ -30,7 +36,7 @@ Set-Alias -Name Archive-MyTask -Value Save-MyTask

#define a hashtable of parameters to splat to Export-ModuleMember
$exportParams = @{
Variable = "myTaskPath","myTaskDefaultCategories","myTaskArchivePath"
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"
Expand Down
24 changes: 10 additions & 14 deletions MyTasksFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,10 @@ Class MyTask {

#check if task is overdue and update
hidden [void]Refresh() {
write-verbose "[CLASS ] Refreshing task $($this.name)"
Write-Verbose "[CLASS ] Refreshing task $($this.name)"
#only mark as overdue if not completed and today is greater than the due date
Write-Verbose "[CLASS ] Comparing $($this.DueDate) due date to $(Get-Date)"
#write-host "Now is $(get-date)"
#write-host "comparing to $($this.duedate)"
#write-host ((Get-Date) -gt $this.DueDate)
#write-host (-Not $this.completed)

if (((Get-Date) -gt $this.DueDate) -AND (-Not $this.completed)) {
$this.Overdue = $True
}
Expand All @@ -52,8 +49,7 @@ Class MyTask {
}

} #refresh



#Constructors
MyTask([string]$Name) {
write-verbose "[CLASS ] Constructing with name: $name"
Expand Down Expand Up @@ -95,7 +91,7 @@ Function _ImportTasks {
$obj.Property | ForEach-Object -Begin {$propHash = [ordered]@{}} -Process {
$propHash.Add($_.name, $_.'#text')
}
$propHash | out-string | write-verbose
$propHash | out-string | write-verbose
Try {
$tmp = New-Object -TypeName MyTask -ArgumentList $propHash.Name, $propHash.DueDate, $propHash.Description, $propHash.Category

Expand Down Expand Up @@ -161,7 +157,7 @@ Function New-MyTask {

# Generate and set the ValidateSet
if (Test-Path -Path $myTaskCategory) {
$arrSet = Get-Content -Path $myTaskCategory | where {$_ -match "\w+"} | foreach {$_.Trim()}
$arrSet = Get-Content -Path $myTaskCategory | where-object {$_ -match "\w+"} | foreach-object {$_.Trim()}
}
else {
$arrSet = $myTaskDefaultCategories
Expand Down Expand Up @@ -315,7 +311,7 @@ Function Set-MyTask {

# Generate and set the ValidateSet
if (Test-Path -Path $myTaskCategory) {
$arrSet = Get-Content -Path $myTaskCategory -Encoding Unicode | where {$_ -match "\w+"} | foreach {$_.Trim()}
$arrSet = Get-Content -Path $myTaskCategory -Encoding Unicode | where-object {$_ -match "\w+"} | foreach-object {$_.Trim()}
}
else {
$arrSet = $myTaskDefaultCategories
Expand Down Expand Up @@ -721,7 +717,7 @@ Function Show-MyTask {
}

#test if task is complete
if ($_ -match '\b100\b.$') {
if ($_ -match '\b100\b$') {
$complete = $True

}
Expand Down Expand Up @@ -812,7 +808,7 @@ Function Complete-MyTask {
Write-Verbose "[PROCESS] Marking task as completed"
#invoke CompleteTask() method
$task.CompleteTask()
Write-Verbose "[PROCESS] $($task | Select *,Completed,TaskModified,TaskID | Out-String)"
Write-Verbose "[PROCESS] $($task | Select-Object *,Completed,TaskModified,TaskID | Out-String)"

#find matching XML node and replace it
Write-Verbose "[PROCESS] Updating task file"
Expand Down Expand Up @@ -940,7 +936,7 @@ Function Remove-MyTaskCategory {
#get current contents
$current = Get-Content -Path $myTaskCategory -Encoding Unicode| where-object {$_ -match "\w+"}
#create backup
$back = Join-Path -path $home\Documents -ChildPath MyTaskCategory.bak
$back = Join-Path -path $mytaskhome -ChildPath MyTaskCategory.bak
Write-Verbose "[BEGIN ] Creating backup copy"
Copy-Item -Path $myTaskCategory -Destination $back -Force
} #begin
Expand Down Expand Up @@ -971,7 +967,7 @@ Function Backup-MyTaskFile {
HelpMessage = "Enter the filename and path for the backup xml file"
)]
[ValidateNotNullorEmpty()]
[string]$Destination = (Join-Path -Path $home\documents -ChildPath "MyTasks_Backup_$(Get-Date -format "yyyyMMdd").xml" ),
[string]$Destination = (Join-Path -Path $mytaskhome -ChildPath "MyTasks_Backup_$(Get-Date -format "yyyyMMdd").xml" ),
[switch]$Passthru

)
Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# MyTasks #

This PowerShell module is designed as a task or simple To-Do manager. The module contains several commands for working with tasks. Task data is stored in an XML file in the user's Documents folder. Here are a few highlights.
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.

Install-Module MyTasks [-scope currentuser]
Task data is stored in an XML file in the user's Documents folder. Here are a few highlights.

## Class based ##
This module requires 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.
Expand All @@ -13,7 +17,7 @@ The Task object includes a Category property. The module will define a default s
+ Remove-MyTaskCategory

## Colorized Output ##
Normally, you will use Get-MyTask to display tasks, all, some or a single item:
Normally, you will use `Get-MyTask` to display tasks, all, some or a single item:

```
PS S:\> get-mytask -name MemoryTools
Expand All @@ -22,10 +26,10 @@ ID Name Description DueDate OverDue Category Progress
-- ---- ----------- ------- ------- -------- --------
8 MemoryTools update module ```7/22/2018 False Projects 10
```
But there is also a command called *Show-MyTask* which 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.
But there is also a command called `Show-MyTask` which 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.

## 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 or when you run Complete-MyTask. Or you can completely delete a task with Remove-MyTask.
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` or when you run `Complete-MyTask`. Or you can completely delete a task with `Remove-MyTask`.

You should read full help and examples for all commands as well as the about_MyTasks help file.

Expand All @@ -42,9 +46,7 @@ You should read full help and examples for all commands as well as the about_MyT
- [Show-MyTask](https://github.com/jdhitsolutions/MyTasks/blob/master/docs/Show-MyTask.md)

## Limitations
This module is currently not intended or supported on PowerShell Core running on Linux or macOS..

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


*last updated 2 January 2018*
*last updated 3 January 2018*
6 changes: 6 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
Changelog for MyTasks

v1.2.0
Modified files to support PowerShell Core
Update help documentation
Updated README
Updated manifest

v1.1.0
Updated verbose messages
moved class definition to functions script
Expand Down
20 changes: 12 additions & 8 deletions docs/Add-MyTaskCategory.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
---
external help file: MyTasks-help.xml
Module Name: MyTasks
online version:
schema: 2.0.0
---

# Add-MyTaskCategory

## SYNOPSIS
Add a custom category for MyTasks

## SYNTAX

```
Add-MyTaskCategory [-Category] <String[]> [-WhatIf] [-Confirm]
Add-MyTaskCategory [-Category] <String[]> [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
By default the MyTasks module ships with default categories of Work, Personal, Customer and other. But you can add your own categories. They will be stored in the Documents folder in a file called MyCategory.txt. It is recommended that you use the MyTaskCategory commands to modify this file. As soon as you add a custom category, the default categories are discarded. If you wish to use them, then add them back with this command. See examples.

## EXAMPLES

### -------------------------- EXAMPLE 1 --------------------------
Expand All @@ -35,10 +38,10 @@ Other
Work
Personal
Team
```

Add several categories and then display them.

## PARAMETERS

### -Category
Expand All @@ -51,39 +54,40 @@ Aliases:

Required: True
Position: 0
Default value:
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```

### -Confirm

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value:
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -WhatIf

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value:
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### 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

### System.String[]
Expand All @@ -93,10 +97,10 @@ Accept wildcard characters: False
### None

## NOTES

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

## RELATED LINKS
[Get-MyTaskCategory]()

[Remove-MyTaskCategory]()
Loading

0 comments on commit b0a1c42

Please sign in to comment.