diff --git a/.github/workflows/CodeAnalysis.yml b/.github/workflows/CodeAnalysis.yml index 479b364..c9e1051 100644 --- a/.github/workflows/CodeAnalysis.yml +++ b/.github/workflows/CodeAnalysis.yml @@ -15,7 +15,7 @@ jobs: name: SonarCloud runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: SonarCloud Scan @@ -31,7 +31,7 @@ jobs: name: PSScriptAnalyzer runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Run PSScriptAnalyzer uses: microsoft/psscriptanalyzer-action@7a0da25f33985767f15f93140306528900744195 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a94dd4a..b156dc2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -18,7 +18,7 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Run PSScriptAnalyzer uses: microsoft/psscriptanalyzer-action@7a0da25f33985767f15f93140306528900744195 with: diff --git a/Public/Functions/Get-Tag.ps1 b/Public/Functions/Get-Tag.ps1 new file mode 100644 index 0000000..3b89b42 --- /dev/null +++ b/Public/Functions/Get-Tag.ps1 @@ -0,0 +1,37 @@ +function Get-Tag { +<# +.SYNOPSIS + Retrieves the current user's tags from Habitica. + +.DESCRIPTION + Calls the Habitica API to return the list of tags defined by the user. + Tags can be used to group tasks like todos, dailies, or habits. + +.EXAMPLE + Get-Tag + + Returns all tags for the authenticated Habitica user. + +.EXAMPLE + Get-Tag | Where-Object { $_.name -eq "Work" } + + Returns the "Work" tag object. + +.EXAMPLE + (Get-Tag).name + + Lists the names of all tags. +#> + [CmdletBinding()] + param() + + process { + try { + $response = Invoke-Api -Uri "/tags" -Method GET + return $response.data + } + catch { + throw "Failed to retrieve tags. Ensure you are authenticated with Connect-Account. Details: $_" + } + } +} diff --git a/Public/Functions/New-Tag.ps1 b/Public/Functions/New-Tag.ps1 new file mode 100644 index 0000000..7e11e47 --- /dev/null +++ b/Public/Functions/New-Tag.ps1 @@ -0,0 +1,39 @@ + +function New-Tag { + <# +.SYNOPSIS + Creates a new tag in Habitica. + +.DESCRIPTION + Calls the Habitica API to create a new tag associated with the authenticated user. + +.PARAMETER Name + The name of the tag to create. + +.EXAMPLE + New-Tag -Name "Work" + + Creates a new tag named "Work". + +.EXAMPLE + "Fitness","Health" | ForEach-Object { New-Tag -Name $_ } + + Creates multiple tags at once. +#> + [CmdletBinding()] + param( + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] + [string]$Name + ) + + process { + try { + $Body = @{ name = $Name } + $response = Invoke-Api -Uri "/tags" -Method POST -Body $Body + return $response.data + } + catch { + throw "Failed to create tag '$Name'. Details: $_" + } + } +} diff --git a/Public/Functions/New-Task.ps1 b/Public/Functions/New-Task.ps1 index eb23235..8e58afd 100644 --- a/Public/Functions/New-Task.ps1 +++ b/Public/Functions/New-Task.ps1 @@ -94,13 +94,19 @@ function New-Task { [Parameter(Mandatory, ParameterSetName = 'Habit', ValueFromPipelineByPropertyName)] [string]$Text, - [Parameter(ValueFromPipelineByPropertyName)] + [Parameter(Mandatory = $false, ParameterSetName = 'Todo', ValueFromPipelineByPropertyName)] + [Parameter(Mandatory = $false, ParameterSetName = 'Daily', ValueFromPipelineByPropertyName)] + [Parameter(Mandatory = $false, ParameterSetName = 'Habit', ValueFromPipelineByPropertyName)] [string]$Alias, - [Parameter(ValueFromPipelineByPropertyName)] + [Parameter(Mandatory = $false, ParameterSetName = 'Todo', ValueFromPipelineByPropertyName)] + [Parameter(Mandatory = $false, ParameterSetName = 'Daily', ValueFromPipelineByPropertyName)] + [Parameter(Mandatory = $false, ParameterSetName = 'Habit', ValueFromPipelineByPropertyName)] [string]$Note, - [Parameter(ValueFromPipelineByPropertyName)] + [Parameter(Mandatory = $false, ParameterSetName = 'Todo', ValueFromPipelineByPropertyName)] + [Parameter(Mandatory = $false, ParameterSetName = 'Daily', ValueFromPipelineByPropertyName)] + [Parameter(Mandatory = $false, ParameterSetName = 'Habit', ValueFromPipelineByPropertyName)] [string[]]$Tags, [Parameter(ValueFromPipelineByPropertyName)] @@ -171,7 +177,20 @@ function New-Task { if ($Alias) { $body.alias = $Alias } if ($Note) { $body.notes = $Note } - if ($Tags) { $body.tags = $Tags } + if ($Tags) { + $tagIds = @() + $allTags = (Invoke-Api -Uri "/tags" -Method GET).data + foreach ($tag in $Tags) { + $match = $allTags | Where-Object { $_.id -ieq $tag -or $_.name -ieq $tag } + if ($match) { + $tagIds += $match.id + } + else { + Write-Warning "Tag '$tag' not found. Skipping." + } + } + if ($tagIds) { $body.tags = $tagIds } + } if ($Checklist) { $body.checklist = $Checklist | ForEach-Object { @{ text = $_ } } } # --- Todo diff --git a/Public/Functions/Remove-Tag.ps1 b/Public/Functions/Remove-Tag.ps1 new file mode 100644 index 0000000..973e180 --- /dev/null +++ b/Public/Functions/Remove-Tag.ps1 @@ -0,0 +1,40 @@ + +function Remove-Tag { + <# +.SYNOPSIS + Deletes a Habitica tag. + +.DESCRIPTION + Calls the Habitica API to delete a tag by its ID. + +.PARAMETER Id + The ID of the tag to delete. + +.EXAMPLE + Remove-Tag -Id "12345678-abcd-1234-abcd-1234567890ab" + + Deletes the specified tag. + +.EXAMPLE + Get-Tag | Where-Object { $_.name -eq "Obsolete" } | Remove-Tag + + Deletes the tag named "Obsolete". +#> + [CmdletBinding(SupportsShouldProcess)] + param( + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [string]$Id + ) + + process { + if ($PSCmdlet.ShouldProcess("Tag ID $Id", "Delete")) { + try { + $response = Invoke-Api -Uri "/tags/$Id" -Method DELETE + return $response.success + } + catch { + throw "Failed to delete tag '$Id'. Details: $_" + } + } + } +} diff --git a/Public/Functions/Set-Tag.ps1 b/Public/Functions/Set-Tag.ps1 new file mode 100644 index 0000000..651da26 --- /dev/null +++ b/Public/Functions/Set-Tag.ps1 @@ -0,0 +1,45 @@ + +function Set-Tag { + <# +.SYNOPSIS + Updates an existing Habitica tag. + +.DESCRIPTION + Calls the Habitica API to update the name of an existing tag by its ID. + +.PARAMETER Id + The ID of the tag to update. + +.PARAMETER Name + The new name for the tag. + +.EXAMPLE + Set-Tag -Id "12345678-abcd-1234-abcd-1234567890ab" -Name "UpdatedTag" + + Renames the specified tag to "UpdatedTag". + +.EXAMPLE + Get-Tag | Where-Object { $_.name -eq "Work" } | Set-Tag -Name "Office" + + Finds the "Work" tag and renames it to "Office". +#> + [CmdletBinding()] + param( + [Parameter(Mandatory, ValueFromPipelineByPropertyName)] + [string]$Id, + + [Parameter(Mandatory)] + [string]$Name + ) + + process { + try { + $Body = @{ name = $Name } + $response = Invoke-Api -Uri "/tags/$Id" -Method PUT -Body $Body + return $response.data + } + catch { + throw "Failed to update tag '$Id'. Details: $_" + } + } +} diff --git a/Public/Functions/Set-Task.ps1 b/Public/Functions/Set-Task.ps1 new file mode 100644 index 0000000..fa90ae0 --- /dev/null +++ b/Public/Functions/Set-Task.ps1 @@ -0,0 +1,150 @@ +function Set-Task { + <# + .SYNOPSIS + Updates an existing Habitica task. + + .DESCRIPTION + Calls the Habitica API to update a task by ID. + Parameters are grouped into sets depending on the task type (`todo`, `daily`, or `habit`). + + .PARAMETER TaskId + The unique identifier of the Habitica task to update. + + .PARAMETER Text + The new title of the task. + + .PARAMETER Notes + The description or details of the task. + + .PARAMETER Type + The type of the task. Valid values: "habit", "daily", "todo". + + .PARAMETER Priority + Priority multiplier for the task. Typical values: 0.1 (trivial), 1 (easy), 1.5 (medium), 2 (hard). + + .PARAMETER Tags + A list of tag names to associate with the task. Tags are automatically resolved to their IDs if they exist. + + .PARAMETER StartDate + (Dailies only) Start date for the daily task. + + .PARAMETER Repeat + (Dailies only) Days of the week the task repeats. Example: @{ su=$false; m=$true; t=$true; w=$true; th=$true; f=$true; s=$false } + + .PARAMETER Frequency + (Dailies only) Interval type. Valid values: "daily", "weekly", "monthly", "yearly". + + .PARAMETER Up + (Habits only) Whether the habit can increment positively. + + .PARAMETER Down + (Habits only) Whether the habit can decrement negatively. + + .EXAMPLE + Set-Task -TaskId "abcd1234" -Type todo -Text "Finish docs" -Priority 2 + + .EXAMPLE + Set-Task -TaskId "abcd1234" -Type daily -StartDate (Get-Date) -Repeat @{ m=$true; t=$true; w=$true } + #> + [CmdletBinding(DefaultParameterSetName = 'Todo')] + param( + # ----------------------- + # Common properties + # ----------------------- + [Parameter(Mandatory, ParameterSetName = 'Todo', ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ParameterSetName = 'Daily', ValueFromPipelineByPropertyName)] + [Parameter(Mandatory, ParameterSetName = 'Habit', ValueFromPipelineByPropertyName)] + [string]$TaskId, + + [Parameter(ParameterSetName = 'Todo', ValueFromPipelineByPropertyName)] + [Parameter(ParameterSetName = 'Daily', ValueFromPipelineByPropertyName)] + [Parameter(ParameterSetName = 'Habit', ValueFromPipelineByPropertyName)] + [string]$Text, + + [Parameter(ParameterSetName = 'Todo', ValueFromPipelineByPropertyName)] + [Parameter(ParameterSetName = 'Daily', ValueFromPipelineByPropertyName)] + [Parameter(ParameterSetName = 'Habit', ValueFromPipelineByPropertyName)] + [string]$Notes, + + [Parameter(ParameterSetName = 'Todo', ValueFromPipelineByPropertyName)] + [Parameter(ParameterSetName = 'Daily', ValueFromPipelineByPropertyName)] + [Parameter(ParameterSetName = 'Habit', ValueFromPipelineByPropertyName)] + [double]$Priority, + + [Parameter(ParameterSetName = 'Todo', ValueFromPipelineByPropertyName)] + [Parameter(ParameterSetName = 'Daily', ValueFromPipelineByPropertyName)] + [Parameter(ParameterSetName = 'Habit', ValueFromPipelineByPropertyName)] + [string[]]$Tags, + + # ----------------------- + # Daily properties + # ----------------------- + [Parameter(ParameterSetName = 'Daily', ValueFromPipelineByPropertyName)] + [datetime]$StartDate, + + [Parameter(ParameterSetName = 'Daily', ValueFromPipelineByPropertyName)] + [hashtable]$Repeat, + + [Parameter(ParameterSetName = 'Daily', ValueFromPipelineByPropertyName)] + [ValidateSet("daily", "weekly", "monthly", "yearly")] + [string]$Frequency, + + # ----------------------- + # Habit properties + # ----------------------- + [Parameter(ParameterSetName = 'Habit', ValueFromPipelineByPropertyName)] + [bool]$Up, + + [Parameter(ParameterSetName = 'Habit', ValueFromPipelineByPropertyName)] + [bool]$Down + ) + + begin { + + } + + process { + $body = @{} + if ($PSBoundParameters.ContainsKey("Text")) { $body.text = $Text } + if ($PSBoundParameters.ContainsKey("Notes")) { $body.notes = $Notes } + if ($PSBoundParameters.ContainsKey("Priority")) { $body.priority = $Priority } + if ($PSBoundParameters.ContainsKey("Type")) { $body.type = $Type } + + if ($Tags) { + $resolvedTags = @() + foreach ($tag in $Tags) { + try { + $habiticaTag = Get-Tag | Where-Object { $_.id -ieq $tag -or $_.name -ieq $tag } + if ($habiticaTag) { + $resolvedTags += $habiticaTag.id + } + else { + Write-Warning "Tag '$tag' does not exist. Skipping..." + } + } + catch { + Write-Warning "Failed to resolve tag '$tag'. Skipping..." + } + } + if ($resolvedTags.Count -gt 0) { + $body.tags = $resolvedTags + } + } + + if ($PSCmdlet.ParameterSetName -eq 'Daily') { + if ($PSBoundParameters.ContainsKey("StartDate")) { $body.startDate = $StartDate.ToString("yyyy-MM-dd") } + if ($PSBoundParameters.ContainsKey("Repeat")) { $body.repeat = $Repeat } + if ($PSBoundParameters.ContainsKey("Frequency")) { $body.frequency = $Frequency } + } + + if ($PSCmdlet.ParameterSetName -eq 'Habit') { + if ($PSBoundParameters.ContainsKey("Up")) { $body.up = $Up } + if ($PSBoundParameters.ContainsKey("Down")) { $body.down = $Down } + } + $response = Invoke-Api -Uri "tasks/$TaskId" -Method PUT -Body $body + if ($response.success) { + Write-Verbose "Task '$Text' updated successfully" + return $response.data + } + } +} diff --git a/docs/Connect-Account.md b/docs/Connect-Account.md index 260027f..53ba9a9 100644 --- a/docs/Connect-Account.md +++ b/docs/Connect-Account.md @@ -54,7 +54,7 @@ Uses Windows Credential Manager prompt to obtain the SecureString password. ### -Client The x-client attribute. -Required by Habitica API. +Required by Habitica API. Format: \-\. Refer to: https://github.com/HabitRPG/habitica/wiki/API-Usage-Guidelines#x-client-header @@ -109,8 +109,8 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## OUTPUTS ## NOTES -Author: Rodrigo Cordeiro -Module: PSHabitica +Author: Rodrigo Cordeiro +Module: PSHabitica This function registers the SecretVault "PSHabitica" automatically if not present. ## RELATED LINKS diff --git a/docs/Get-Tag.md b/docs/Get-Tag.md new file mode 100644 index 0000000..76920e1 --- /dev/null +++ b/docs/Get-Tag.md @@ -0,0 +1,57 @@ +--- +external help file: pshabitica-help.xml +Module Name: pshabitica +online version: +schema: 2.0.0 +--- + +# Get-Tag + +## SYNOPSIS +Retrieves the current user's tags from Habitica. + +## SYNTAX + +``` +Get-Tag [] +``` + +## DESCRIPTION +Calls the Habitica API to return the list of tags defined by the user. +Tags can be used to group tasks like todos, dailies, or habits. + +## EXAMPLES + +### EXEMPLO 1 +``` +Get-Tag +``` + +Returns all tags for the authenticated Habitica user. + +### EXEMPLO 2 +``` +Get-Tag | Where-Object { $_.name -eq "Work" } +``` + +Returns the "Work" tag object. + +### EXEMPLO 3 +``` +(Get-Tag).name +``` + +Lists the names of all tags. + +## 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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/New-Tag.md b/docs/New-Tag.md new file mode 100644 index 0000000..2e25d53 --- /dev/null +++ b/docs/New-Tag.md @@ -0,0 +1,64 @@ +--- +external help file: pshabitica-help.xml +Module Name: pshabitica +online version: +schema: 2.0.0 +--- + +# New-Tag + +## SYNOPSIS +Creates a new tag in Habitica. + +## SYNTAX + +``` +New-Tag [-Name] [] +``` + +## DESCRIPTION +Calls the Habitica API to create a new tag associated with the authenticated user. + +## EXAMPLES + +### EXEMPLO 1 +``` +New-Tag -Name "Work" +``` + +Creates a new tag named "Work". + +### EXEMPLO 2 +``` +"Fitness","Health" | ForEach-Object { New-Tag -Name $_ } +``` + +Creates multiple tags at once. + +## PARAMETERS + +### -Name +The name of the tag to create. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName, ByValue) +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/New-Task.md b/docs/New-Task.md index ce03b70..86c8d1e 100644 --- a/docs/New-Task.md +++ b/docs/New-Task.md @@ -77,7 +77,7 @@ Valid values are: "todo", "daily", "habit". ```yaml Type: String Parameter Sets: (All) -Aliases: Title +Aliases: Required: True Position: Named diff --git a/docs/Remove-Tag.md b/docs/Remove-Tag.md new file mode 100644 index 0000000..800d98b --- /dev/null +++ b/docs/Remove-Tag.md @@ -0,0 +1,95 @@ +--- +external help file: pshabitica-help.xml +Module Name: pshabitica +online version: +schema: 2.0.0 +--- + +# Remove-Tag + +## SYNOPSIS +Deletes a Habitica tag. + +## SYNTAX + +``` +Remove-Tag [-Id] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Calls the Habitica API to delete a tag by its ID. + +## EXAMPLES + +### EXEMPLO 1 +``` +Remove-Tag -Id "12345678-abcd-1234-abcd-1234567890ab" +``` + +Deletes the specified tag. + +### EXEMPLO 2 +``` +Get-Tag | Where-Object { $_.name -eq "Obsolete" } | Remove-Tag +``` + +Deletes the tag named "Obsolete". + +## PARAMETERS + +### -Id +The ID of the tag to delete. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Set-Tag.md b/docs/Set-Tag.md new file mode 100644 index 0000000..4405fff --- /dev/null +++ b/docs/Set-Tag.md @@ -0,0 +1,79 @@ +--- +external help file: pshabitica-help.xml +Module Name: pshabitica +online version: +schema: 2.0.0 +--- + +# Set-Tag + +## SYNOPSIS +Updates an existing Habitica tag. + +## SYNTAX + +``` +Set-Tag [-Id] [-Name] [] +``` + +## DESCRIPTION +Calls the Habitica API to update the name of an existing tag by its ID. + +## EXAMPLES + +### EXEMPLO 1 +``` +Set-Tag -Id "12345678-abcd-1234-abcd-1234567890ab" -Name "UpdatedTag" +``` + +Renames the specified tag to "UpdatedTag". + +### EXEMPLO 2 +``` +Get-Tag | Where-Object { $_.name -eq "Work" } | Set-Tag -Name "Office" +``` + +Finds the "Work" tag and renames it to "Office". + +## PARAMETERS + +### -Id +The ID of the tag to update. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Name +The new name for the tag. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/Set-Task.md b/docs/Set-Task.md new file mode 100644 index 0000000..cb4ee99 --- /dev/null +++ b/docs/Set-Task.md @@ -0,0 +1,214 @@ +--- +external help file: pshabitica-help.xml +Module Name: pshabitica +online version: +schema: 2.0.0 +--- + +# Set-Task + +## SYNOPSIS +Updates an existing Habitica task. + +## SYNTAX + +### Todo (Default) +``` +Set-Task -TaskId [-Text ] [-Notes ] [-Priority ] [-Tags ] + [] +``` + +### Habit +``` +Set-Task -TaskId [-Text ] [-Notes ] [-Priority ] [-Tags ] + [-Up ] [-Down ] [] +``` + +### Daily +``` +Set-Task -TaskId [-Text ] [-Notes ] [-Priority ] [-Tags ] + [-StartDate ] [-Repeat ] [-Frequency ] [] +``` + +## DESCRIPTION +Calls the Habitica API to update a task by ID. +Parameters are grouped into sets depending on the task type (\`todo\`, \`daily\`, or \`habit\`). + +## EXAMPLES + +### EXEMPLO 1 +``` +Set-Task -TaskId "abcd1234" -Type todo -Text "Finish docs" -Priority 2 +``` + +### EXEMPLO 2 +``` +Set-Task -TaskId "abcd1234" -Type daily -StartDate (Get-Date) -Repeat @{ m=$true; t=$true; w=$true } +``` + +## PARAMETERS + +### -TaskId +The unique identifier of the Habitica task to update. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Text +The new title of the task. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Notes +The description or details of the task. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Priority +Priority multiplier for the task. +Typical values: 0.1 (trivial), 1 (easy), 1.5 (medium), 2 (hard). + +```yaml +Type: Double +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: 0 +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Tags +A list of tag names to associate with the task. +Tags are automatically resolved to their IDs if they exist. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -StartDate +(Dailies only) Start date for the daily task. + +```yaml +Type: DateTime +Parameter Sets: Daily +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Repeat +(Dailies only) Days of the week the task repeats. +Example: @{ su=$false; m=$true; t=$true; w=$true; th=$true; f=$true; s=$false } + +```yaml +Type: Hashtable +Parameter Sets: Daily +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Frequency +(Dailies only) Interval type. +Valid values: "daily", "weekly", "monthly", "yearly". + +```yaml +Type: String +Parameter Sets: Daily +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Up +(Habits only) Whether the habit can increment positively. + +```yaml +Type: Boolean +Parameter Sets: Habit +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Down +(Habits only) Whether the habit can decrement negatively. + +```yaml +Type: Boolean +Parameter Sets: Habit +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: True (ByPropertyName) +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 + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/pshabitica-help.xml b/docs/pshabitica-help.xml index 73a2939..ce9ec6e 100644 --- a/docs/pshabitica-help.xml +++ b/docs/pshabitica-help.xml @@ -18,7 +18,7 @@ Client - The x-client attribute. Required by Habitica API. Format: <username>-<appname>. Refer to: https://github.com/HabitRPG/habitica/wiki/API-Usage-Guidelines#x-client-header + The x-client attribute. Required by Habitica API. Format: <username>-<appname>. Refer to: https://github.com/HabitRPG/habitica/wiki/API-Usage-Guidelines#x-client-header String @@ -57,7 +57,7 @@ Client - The x-client attribute. Required by Habitica API. Format: <username>-<appname>. Refer to: https://github.com/HabitRPG/habitica/wiki/API-Usage-Guidelines#x-client-header + The x-client attribute. Required by Habitica API. Format: <username>-<appname>. Refer to: https://github.com/HabitRPG/habitica/wiki/API-Usage-Guidelines#x-client-header String @@ -95,9 +95,7 @@ - Author: Rodrigo Cordeiro -Module: PSHabitica -This function registers the SecretVault "PSHabitica" automatically if not present. + Author: Rodrigo Cordeiro Module: PSHabitica This function registers the SecretVault "PSHabitica" automatically if not present. @@ -182,6 +180,56 @@ This function registers the SecretVault "PSHabitica" automatically if not presen + + + Get-Tag + Get + Tag + + Retrieves the current user's tags from Habitica. + + + + Calls the Habitica API to return the list of tags defined by the user. Tags can be used to group tasks like todos, dailies, or habits. + + + + Get-Tag + + + + + + + + + + + + + -------------------------- EXEMPLO 1 -------------------------- + Get-Tag + + Returns all tags for the authenticated Habitica user. + + + + -------------------------- EXEMPLO 2 -------------------------- + Get-Tag | Where-Object { $_.name -eq "Work" } + + Returns the "Work" tag object. + + + + -------------------------- EXEMPLO 3 -------------------------- + (Get-Tag).name + + Lists the names of all tags. + + + + + Get-User @@ -236,6 +284,74 @@ This function registers the SecretVault "PSHabitica" automatically if not presen + + + New-Tag + New + Tag + + Creates a new tag in Habitica. + + + + Calls the Habitica API to create a new tag associated with the authenticated user. + + + + New-Tag + + Name + + The name of the tag to create. + + String + + String + + + None + + + + + + Name + + The name of the tag to create. + + String + + String + + + None + + + + + + + + + + + + -------------------------- EXEMPLO 1 -------------------------- + New-Tag -Name "Work" + + Creates a new tag named "Work". + + + + -------------------------- EXEMPLO 2 -------------------------- + "Fitness","Health" | ForEach-Object { New-Tag -Name $_ } + + Creates multiple tags at once. + + + + + New-Task @@ -251,7 +367,7 @@ This function registers the SecretVault "PSHabitica" automatically if not presen New-Task - + Type The type of the task. Valid values are: "todo", "daily", "habit". @@ -362,7 +478,7 @@ This function registers the SecretVault "PSHabitica" automatically if not presen New-Task - + Type The type of the task. Valid values are: "todo", "daily", "habit". @@ -509,7 +625,7 @@ This function registers the SecretVault "PSHabitica" automatically if not presen New-Task - + Type The type of the task. Valid values are: "todo", "daily", "habit". @@ -630,7 +746,7 @@ This function registers the SecretVault "PSHabitica" automatically if not presen - + Type The type of the task. Valid values are: "todo", "daily", "habit". @@ -846,4 +962,557 @@ This function registers the SecretVault "PSHabitica" automatically if not presen + + + Remove-Tag + Remove + Tag + + Deletes a Habitica tag. + + + + Calls the Habitica API to delete a tag by its ID. + + + + Remove-Tag + + Id + + The ID of the tag to delete. + + String + + String + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + + + + Id + + The ID of the tag to delete. + + String + + String + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + + + + + + + + + + -------------------------- EXEMPLO 1 -------------------------- + Remove-Tag -Id "12345678-abcd-1234-abcd-1234567890ab" + + Deletes the specified tag. + + + + -------------------------- EXEMPLO 2 -------------------------- + Get-Tag | Where-Object { $_.name -eq "Obsolete" } | Remove-Tag + + Deletes the tag named "Obsolete". + + + + + + + + Set-Tag + Set + Tag + + Updates an existing Habitica tag. + + + + Calls the Habitica API to update the name of an existing tag by its ID. + + + + Set-Tag + + Id + + The ID of the tag to update. + + String + + String + + + None + + + Name + + The new name for the tag. + + String + + String + + + None + + + + + + Id + + The ID of the tag to update. + + String + + String + + + None + + + Name + + The new name for the tag. + + String + + String + + + None + + + + + + + + + + + + -------------------------- EXEMPLO 1 -------------------------- + Set-Tag -Id "12345678-abcd-1234-abcd-1234567890ab" -Name "UpdatedTag" + + Renames the specified tag to "UpdatedTag". + + + + -------------------------- EXEMPLO 2 -------------------------- + Get-Tag | Where-Object { $_.name -eq "Work" } | Set-Tag -Name "Office" + + Finds the "Work" tag and renames it to "Office". + + + + + + + + Set-Task + Set + Task + + Updates an existing Habitica task. + + + + Calls the Habitica API to update a task by ID. Parameters are grouped into sets depending on the task type (`todo`, `daily`, or `habit`). + + + + Set-Task + + TaskId + + The unique identifier of the Habitica task to update. + + String + + String + + + None + + + Text + + The new title of the task. + + String + + String + + + None + + + Notes + + The description or details of the task. + + String + + String + + + None + + + Priority + + Priority multiplier for the task. Typical values: 0.1 (trivial), 1 (easy), 1.5 (medium), 2 (hard). + + Double + + Double + + + 0 + + + Tags + + A list of tag names to associate with the task. Tags are automatically resolved to their IDs if they exist. + + String[] + + String[] + + + None + + + StartDate + + (Dailies only) Start date for the daily task. + + DateTime + + DateTime + + + None + + + Repeat + + (Dailies only) Days of the week the task repeats. Example: @{ su=$false; m=$true; t=$true; w=$true; th=$true; f=$true; s=$false } + + Hashtable + + Hashtable + + + None + + + Frequency + + (Dailies only) Interval type. Valid values: "daily", "weekly", "monthly", "yearly". + + String + + String + + + None + + + + Set-Task + + TaskId + + The unique identifier of the Habitica task to update. + + String + + String + + + None + + + Text + + The new title of the task. + + String + + String + + + None + + + Notes + + The description or details of the task. + + String + + String + + + None + + + Priority + + Priority multiplier for the task. Typical values: 0.1 (trivial), 1 (easy), 1.5 (medium), 2 (hard). + + Double + + Double + + + 0 + + + Tags + + A list of tag names to associate with the task. Tags are automatically resolved to their IDs if they exist. + + String[] + + String[] + + + None + + + Up + + (Habits only) Whether the habit can increment positively. + + Boolean + + Boolean + + + False + + + Down + + (Habits only) Whether the habit can decrement negatively. + + Boolean + + Boolean + + + False + + + + + + TaskId + + The unique identifier of the Habitica task to update. + + String + + String + + + None + + + Text + + The new title of the task. + + String + + String + + + None + + + Notes + + The description or details of the task. + + String + + String + + + None + + + Priority + + Priority multiplier for the task. Typical values: 0.1 (trivial), 1 (easy), 1.5 (medium), 2 (hard). + + Double + + Double + + + 0 + + + Tags + + A list of tag names to associate with the task. Tags are automatically resolved to their IDs if they exist. + + String[] + + String[] + + + None + + + StartDate + + (Dailies only) Start date for the daily task. + + DateTime + + DateTime + + + None + + + Repeat + + (Dailies only) Days of the week the task repeats. Example: @{ su=$false; m=$true; t=$true; w=$true; th=$true; f=$true; s=$false } + + Hashtable + + Hashtable + + + None + + + Frequency + + (Dailies only) Interval type. Valid values: "daily", "weekly", "monthly", "yearly". + + String + + String + + + None + + + Up + + (Habits only) Whether the habit can increment positively. + + Boolean + + Boolean + + + False + + + Down + + (Habits only) Whether the habit can decrement negatively. + + Boolean + + Boolean + + + False + + + + + + + + + + + + -------------------------- EXEMPLO 1 -------------------------- + Set-Task -TaskId "abcd1234" -Type todo -Text "Finish docs" -Priority 2 + + + + + + -------------------------- EXEMPLO 2 -------------------------- + Set-Task -TaskId "abcd1234" -Type daily -StartDate (Get-Date) -Repeat @{ m=$true; t=$true; w=$true } + + + + + + + \ No newline at end of file diff --git a/docs/pshabitica.md b/docs/pshabitica.md index c4993a2..2db3250 100644 --- a/docs/pshabitica.md +++ b/docs/pshabitica.md @@ -14,12 +14,24 @@ Locale: pt-br ### [Connect-Account](Connect-Account.md) {{ Fill in the Description }} -### [Get-Hello](Get-Hello.md) +### [Get-Tag](Get-Tag.md) {{ Fill in the Description }} ### [Get-User](Get-User.md) {{ Fill in the Description }} +### [New-Tag](New-Tag.md) +{{ Fill in the Description }} + ### [New-Task](New-Task.md) {{ Fill in the Description }} +### [Remove-Tag](Remove-Tag.md) +{{ Fill in the Description }} + +### [Set-Tag](Set-Tag.md) +{{ Fill in the Description }} + +### [Set-Task](Set-Task.md) +{{ Fill in the Description }} + diff --git a/pshabitica.psd1 b/pshabitica.psd1 index bcc48c4..d1c91d3 100644 Binary files a/pshabitica.psd1 and b/pshabitica.psd1 differ diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..adbfc5a --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,13 @@ +sonar.projectKey=rodcordeiro_pshabitica +sonar.organization=rodcordeiro + +# This is the name and version displayed in the SonarCloud UI. +sonar.projectName=PSHabitica +sonar.projectVersion=0.1 + + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +sonar.sources=. + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 \ No newline at end of file