zmoog / toggl-track

Toggl Track CLI
Apache License 2.0
0 stars 1 forks source link

Add NDJSON as output format #7

Closed zmoog closed 1 year ago

zmoog commented 1 year ago

I need something like this:


$ tgl --format text entries --project-id 178435728 list --start-date 2023-01-26 --end-date 2023-01-27

                                                               Time Entries                                                                

  At           Description                                                                  Start      Stop       Duration   Tags          
 ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 
  2023-01-26   Community: Allow parsing of IPv6 addresses in ingest pipeline                10:25 PM   10:54 PM   0:28       type:support  
  2023-01-26   Community: Fix parsing error client port is blank and adjust for timeStamp   09:45 PM   10:25 PM   0:40       type:support  
  2023-02-03   Community: Fix parsing error client port is blank and adjust for timeStamp   09:45 PM   09:45 PM   0:00       type:support  
  2023-02-03   Community: Fix parsing error client port is blank and adjust for timeStamp   09:45 PM   09:45 PM   0:00       type:support  
  2023-01-26   Community: Azure Signin Module authentication_processing_details Issue       08:39 PM   09:45 PM   1:05       type:support  
  2023-01-26   Community: Azure Signin Module authentication_processing_details Issue       05:13 PM   06:58 PM   1:44       type:support  
  2023-01-26   Community: Azure Signin Module authentication_processing_details Issue       03:55 PM   04:48 PM   0:52       type:support  
  2023-01-26   Drop header log line in CloudFront events                                    03:47 PM   03:55 PM   0:08       type:support  
  2023-01-26   ElasticOnAzure: questions from Deniz Coskun                                  03:03 PM   03:47 PM   0:43       type:support  
  2023-01-26   Cloud Monitoring - Weekly                                                    01:01 PM   02:30 PM   1:29       type:meeting  
  2023-01-26   sync                                                                         12:06 PM   12:35 PM   0:28       type:sync     
  2023-01-26   gather town                                                                  11:31 AM   12:06 PM   0:35       type:meeting  
  2023-01-26   azure2: follow up                                                            10:55 AM   11:31 AM   0:35       type:goal     
  2023-01-26   sync                                                                         08:24 AM   10:55 AM   2:31       type:sync     
 ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 
                                                                                                       Total      11:24                    

$ tgl --format ndjson entries --project-id 178435728 list --start-date 2023-01-26 --end-date 2023-01-27 

{"id": 2819125097, "workspace_id": 1815018, "user_id": 2621333, "project_id": 178435728, "task_id": null, "billable": false, "at": "2023-01-26T22:54:33+00:00", "description": "Community: Allow parsing of IPv6 addresses in ingest pipeline", "start": "2023-01-26T22:25:35+00:00", "stop": "2023-01-26T22:54:33+00:00", "duration": 1738, "tags": ["type:support"]}
{"id": 2819082262, "workspace_id": 1815018, "user_id": 2621333, "project_id": 178435728, "task_id": null, "billable": false, "at": "2023-01-26T22:25:35+00:00", "description": "Community: Fix parsing error client port is blank and adjust for timeStamp", "start": "2023-01-26T21:45:11+00:00", "stop": "2023-01-26T22:25:35+00:00", "duration": 2424, "tags": ["type:support"]}
{"id": 2819082247, "workspace_id": 1815018, "user_id": 2621333, "project_id": 178435728, "task_id": null, "billable": false, "at": "2023-02-03T07:46:39+00:00", "description": "Community: Fix parsing error client port is blank and adjust for timeStamp", "start": "2023-01-26T21:45:10+00:00", "stop": "2023-01-26T21:45:11+00:00", "duration": 1, "tags": ["type:support"]}
{"id": 2819082217, "workspace_id": 1815018, "user_id": 2621333, "project_id": 178435728, "task_id": null, "billable": false, "at": "2023-02-03T07:46:39+00:00", "description": "Community: Fix parsing error client port is blank and adjust for timeStamp", "start": "2023-01-26T21:45:08+00:00", "stop": "2023-01-26T21:45:10+00:00", "duration": 2, "tags": ["type:support"]}
{"id": 2819003151, "workspace_id": 1815018, "user_id": 2621333, "project_id": 178435728, "task_id": null, "billable": false, "at": "2023-01-26T21:45:09+00:00", "description": "Community: Azure Signin Module authentication_processing_details Issue", "start": "2023-01-26T20:39:47+00:00", "stop": "2023-01-26T21:45:09+00:00", "duration": 3922, "tags": ["type:support"]}
{"id": 2818714203, "workspace_id": 1815018, "user_id": 2621333, "project_id": 178435728, "task_id": null, "billable": false, "at": "2023-01-26T18:58:23+00:00", "description": "Community: Azure Signin Module authentication_processing_details Issue", "start": "2023-01-26T17:13:25+00:00", "stop": "2023-01-26T18:58:23+00:00", "duration": 6298, "tags": ["type:support"]}
{"id": 2818566057, "workspace_id": 1815018, "user_id": 2621333, "project_id": 178435728, "task_id": null, "billable": false, "at": "2023-01-26T16:48:22+00:00", "description": "Community: Azure Signin Module authentication_processing_details Issue", "start": "2023-01-26T15:55:39+00:00", "stop": "2023-01-26T16:48:22+00:00", "duration": 3163, "tags": ["type:support"]}
{"id": 2818549545, "workspace_id": 1815018, "user_id": 2621333, "project_id": 178435728, "task_id": null, "billable": false, "at": "2023-01-26T15:55:39+00:00", "description": "Drop header log line in CloudFront events", "start": "2023-01-26T15:47:14+00:00", "stop": "2023-01-26T15:55:39+00:00", "duration": 505, "tags": ["type:support"]}
{"id": 2818461010, "workspace_id": 1815018, "user_id": 2621333, "project_id": 178435728, "task_id": null, "billable": false, "at": "2023-01-26T15:47:14+00:00", "description": "ElasticOnAzure: questions from Deniz Coskun", "start": "2023-01-26T15:03:41+00:00", "stop": "2023-01-26T15:47:14+00:00", "duration": 2613, "tags": ["type:support"]}
{"id": 2818271775, "workspace_id": 1815018, "user_id": 2621333, "project_id": 178435728, "task_id": null, "billable": false, "at": "2023-01-26T14:30:36+00:00", "description": "Cloud Monitoring - Weekly", "start": "2023-01-26T13:01:35+00:00", "stop": "2023-01-26T14:30:36+00:00", "duration": 5341, "tags": ["type:meeting"]}
{"id": 2818128524, "workspace_id": 1815018, "user_id": 2621333, "project_id": 178435728, "task_id": null, "billable": false, "at": "2023-01-26T12:35:31+00:00", "description": "sync", "start": "2023-01-26T12:06:40+00:00", "stop": "2023-01-26T12:35:31+00:00", "duration": 1731, "tags": ["type:sync"]}
{"id": 2818075670, "workspace_id": 1815018, "user_id": 2621333, "project_id": 178435728, "task_id": null, "billable": false, "at": "2023-01-26T12:06:40+00:00", "description": "gather town", "start": "2023-01-26T11:31:30+00:00", "stop": "2023-01-26T12:06:40+00:00", "duration": 2110, "tags": ["type:meeting"]}
{"id": 2818022697, "workspace_id": 1815018, "user_id": 2621333, "project_id": 178435728, "task_id": null, "billable": false, "at": "2023-01-26T11:31:31+00:00", "description": "azure2: follow up", "start": "2023-01-26T10:55:58+00:00", "stop": "2023-01-26T11:31:31+00:00", "duration": 2133, "tags": ["type:goal"]}
{"id": 2817783218, "workspace_id": 1815018, "user_id": 2621333, "project_id": 178435728, "task_id": null, "billable": false, "at": "2023-01-26T10:55:58+00:00", "description": "sync", "start": "2023-01-26T08:24:19+00:00", "stop": "2023-01-26T10:55:58+00:00", "duration": 9099, "tags": ["type:sync"]}

And this is the group by version:

$ tgl --format text entries --project-id 178435728 group-by --field initiative --start-date 2023-01-26 --end-date 2023-01-27

                      Time Entries                      

  initiative                                  Duration  
 ────────────────────────────────────────────────────── 
  Community                                   4:52      
  sync                                        3:00      
  Cloud Monitoring - Weekly                   1:29      
  ElasticOnAzure                              0:43      
  azure2                                      0:35      
  gather town                                 0:35      
  Drop header log line in CloudFront events   0:08      
 ────────────────────────────────────────────────────── 
  Total                                       11:24     

$ tgl --format ndjson entries --project-id 178435728 group-by --field initiative --start-date 2023-01-26 --end-date 2023-01-27

{"field": "initiative", "name": "Community", "duration": 17548}
{"field": "initiative", "name": "sync", "duration": 10830}
{"field": "initiative", "name": "Cloud Monitoring - Weekly", "duration": 5341}
{"field": "initiative", "name": "ElasticOnAzure", "duration": 2613}
{"field": "initiative", "name": "azure2", "duration": 2133}
{"field": "initiative", "name": "gather town", "duration": 2110}
{"field": "initiative", "name": "Drop header log line in CloudFront events", "duration": 505}
zmoog commented 1 year ago

Closed by #11