Git Product home page Git Product logo

pstoggl's Introduction

PSToggl Logo
PSToggl

A fully featured Toggl client for your PowerShell - based on Toggl's API v8

PowerShell Gallery Downloads Build status for master Build status for develop Open Source Helpers codecov Code Coverage


Features

PSToggl perfectly integrates in your existing PowerShell environment, independent of the operating system you want to work with. It makes heavy use of PowerShells pipeline abilities and integrates with other modules like PSJiraJiraPS, PSExcel, PSHipchat and so on. It helps you to increase your productivity by providing extended reporting features, migration&sync features (e.g. Toggl -> JIRA work logs) and a robust interactive PowerShell client.

As you might already know from git (posh-git) PSToggl shows information like the current timer / project at your PowerShell prompt, extends auto completion, provides aliases and templates, and much more.

Contents

  1. Features
  2. Contents
  3. Getting started
    • Installation
    • Configuration
  4. How to use
  5. License

Getting started

Installation

It's recommended to use Install-Module to install PSToggl:

#Running PowerShell as Administrator - Install globally
Install-Module PSToggl

#Without Administrator privileges - Only for the current user
Install-Module PSToggl -Scope CurrentUser

Alternatively, just clone this repo and import PSToggl:

git clone https://github.com/clijsters/PSToggl
Import-Module PSToggl/PSToggl/PSToggl/PSToggl.psm1 # Yeah, 4 times

Configuration

To set your Personal Access Token and your default workspace (yeah I know), create a ~/.PSToggl JSON File with the following content:

{
    "APIKey": "ffffffffffffffffffffffffffffffff",
    "Workspace": 1234567
}

In future releases, this cmdlet will use its own config store and securestrings.

How to use

The best way to become familiar with PSToggl is to use Get-Help

PS> Get-Help about_PSToggl
PS> Get-Help Start-TogglEntry
PS> # And so on

Start a new Timer

PS> Start-TogglEntry "Getting started with PSToggl"

Change the currently running Timer

PS> Get-TogglEntry -Current | Add-TogglTag "educational"

Get all Time Entries for a specified Project, which are not billed and tag them

PS> Get-TogglProject "homepage" | Get-TogglEntry | Where-Object {-not $_.billed} | Add-TogglTag "overdue"

Use the output of Measure-Command to create a new Entry

PS> Measure-Command {mvn -U compile} | New-TogglEntry "Wasting time with coffee..."

PS> Measure-Command {git commit} | New-TogglEntry "Writing well formatted, meaningful git commit messages" -Tags @("efficiency", "Drumherum")

Beta Features & special use cases

If you have tasks, repeating with the same configuration (Tags, project, title), you probably don't want to type the whole timer properties every time.
For this case, we use templates. Where the Toggl Desktop client suggests timer configurations based on your previous runned timers, PSToggl introduces templates.

Theses templates - once configured - give you the ability to quickly start a timer with a defined name, project, client, tags, ...

There are two types of templates. Full templates and configuration templates. The latter is without a title.

Tab completion based on previous entered information will also be supported to mimic the behavior of Toggl Desktop. (And because it makes it much much faster to use Cmdlets)

PS> Start-TogglEntry -Template vcs
PS> git checkout master
PS> git merge dev --no-ff --no-commit
PS> vim pom.xml
PS> #[...]
PS> git add pom.xml
PS> git commit -m "Merge dev branch and increase version number"
PS> git push fork dev
PS> Invoke-Chrome -bookmark GitLab
PS> Stop-TogglEntry -PassThrough | Select Minutes
PS> #Stop-TogglEntry -PassThrough | New-JiraWorklog -Issue Proj-12

Test Coverage

Current

codecov test coverage sunburst

Historical

codecov test coverage graph

pstoggl's People

Contributors

clijsters avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pstoggl's Issues

Stop-TogglEntry doesn't appear to be in v1.3.24 in PSGallery

I've tried this in 7.1.0-preview.2 and 5.1.18362.752

PS C:\Wittionary> Get-Command -Module PSToggl
PS C:\Wittionary> Install-Module pstoggl -MinimumVersion 1.3.24

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy
value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): a
PS C:\Wittionary> Get-Command -Module PSToggl

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Get-TogglClient                                    1.3.24     PSToggl
Function        Get-TogglEntry                                     1.3.24     PSToggl
Function        Get-TogglProject                                   1.3.24     PSToggl
Function        Get-TogglTag                                       1.3.24     PSToggl
Function        New-TogglProject                                   1.3.24     PSToggl
Function        Start-TogglEntry                                   1.3.24     PSToggl
Function        Write-RunningTogglEntry                            1.3.24     PSToggl

Migrate to Pester 5

Current behaviour:

Build fails, because the whole testing setup is made for Pester <4.9.x, and the Install-Script for AppVeyor installs the latest Pester-version (5.0.x)

Error:

----               
C:\projects\pstoggl
. .\AppVeyor\Test.ps1
Current working directory: C:\projects\pstoggl
You are using Legacy parameter set that adapts Pester 5 syntax to Pester 4 syntax. This parameter set is deprecated, and does not work 100%. The -Strict and -PesterOption parameters are ignored, and providing advanced configuration to -Path (-Script), and -CodeCoverage via a hash table does not work. Please refer to https://github.com/pester/Pester/releases/tag/5.0.1#legacy-parameter-set for more information.
Starting discovery in 20 files.
Discovery finished in 4.64s.
[-] General code style compliance.Module 'C:\projects\pstoggl\.codecovio\CodeCovIo.psm1'.passes the PSScriptAnalyzer Rule PSAlignAssignmentStatement 247ms (110ms|137ms)
 ValidationMetadataException: The argument is null. Provide a valid value for the argument, and then try running the command again.
 ParameterBindingValidationException: Cannot validate argument on parameter 'Path'. The argument is null. Provide a valid value for the argument, and then try running the command again.
 at <ScriptBlock>, C:\projects\pstoggl\PSToggl\PSToggl.Tests.ps1:15
[-] General code style compliance.Module 'C:\projects\pstoggl\.codecovio\CodeCovIo.psm1'.passes the PSScriptAnalyzer Rule PSAvoidUsingCmdletAliases 12ms (9ms|3ms)
 ValidationMetadataException: The argument is null. Provide a valid value for the argument, and then try running the command again.
 ParameterBindingValidationException: Cannot validate argument on parameter 'Path'. The argument is null. Provide a valid value for the argument, and then try running the command again.
 at <ScriptBlock>, C:\projects\pstoggl\PSToggl\PSToggl.Tests.ps1:15

And

Should : Legacy Should syntax (without dashes) is not supported in Pester 5. Please refer to migration guide at: https://pester.dev/docs/migrations/v3-to-v4
At C:\projects\pstoggl\Tests\PSToggl\Private\ConvertTo-TogglTask.Tests.ps1:40 char:37
+                 {$out.ToString()} | Should Not Throw
+                                     ~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Should

Solution

Migrate to Pester 5.x

This basically involves:

  • Changing invocation in AppVeyor/Test.ps1
  • Remove version parameter from Install-Module in AppVeyor/Install.ps1
  • Assert-MockCalled should be replaced with Should -Invoke
  • You might want to take a look at the migration guide.

Quickfix until then:
Fix version to <=4.9.9 in AppVeyor/Install.ps1


Possible improvements:

While the coverage is overall quite ok, there is room for improvement for test structure in general.

Use Classes instead of converters

This issue is for brainstorming and to share ideas about using Classes instead of ConvertTo functions.

Classes are a nice modern feature of PowerShell but it's not compatible with versions older than PowerShell 5.

  • Is it worth to let the converters be a fallback and use classes where possible?
  • How much users use PowerShell < v5?
  • What are benefits for Class?
  • What are benefits for custom Converters?

Every public cmdlet should have a -Workspace parameter

Workspaces are an integral part of Toggl and its API. To fully support (mostly) every feature of Toggl, consistent support and accounting of the -Workspace parameter is crucial.

The parameter must be optional for every cmdlet, and should default to the users default workspace. If provided, it is necessary, that every member of the call chain (including private functions and cmdlets of PSToggl) respects that parameter and doesn't throw it away.

This feature isn't up-for-grabs, as I already started to implement it. Maybe that will change in the future, as my days unfortunately only have around 24 hours.

Error: Invalid character 'i' in literal true

Hi @Clijsters, thanks for this great project.

In the new version (1.2) when start new toggle entry by Start-TogglEntry the script throw error:
invalid character 'i' in literal true (expecting 'r').

The error is fired when Invoke-TogglMethod function start the Invoke-RestMethod function.

I notice the error is caused by last edit at this row.

Installing prior version (1.1) everything go right.

Stop-TogglEntry is not recognized as the name of a cmdlet

Stop-TogglEntry : The term 'Stop-TogglEntry' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:1

  • Stop-TogglEntry
  •   + CategoryInfo          : ObjectNotFound: (Stop-TogglEntry:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    

403 forbidden with every cmdlet

I'm getting a 403 forbidden when using any cmdlet. I tested my API key using curl and was able to get a valid response so my thought is that my .PSToggl JSON is either malformed or in the wrong directory. I cd'd to ~ and created the .PSToggl there.
I copy/pasted my key straight from the terminal where I received a 200 response with curl.

Here's my JSON (API key string and workspace integer have been changed):

PS C:\Users\pvl_user> cat .\.PSToggl
{
"APIKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"Workspace": 1234567
}
PS C:\Users\pvl_user> 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.