@beauraines/toggl-cli 0.10.10 → 0.10.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,7 +14,7 @@ jobs:
14
14
 
15
15
  strategy:
16
16
  matrix:
17
- node-version: [16.x]
17
+ node-version: [16.x,18.x]
18
18
 
19
19
  steps:
20
20
  - uses: actions/checkout@v3
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.10.11](https://github.com/beauraines/toggl-cli/compare/v0.10.10...v0.10.11) (2023-03-19)
6
+
7
+
8
+ ### Features
9
+
10
+ * improvements to the ls command ([#52](https://github.com/beauraines/toggl-cli/issues/52)) ([5c9effc](https://github.com/beauraines/toggl-cli/commit/5c9effc10f2c85435441d1cb3bdbb1e821df88b3))
11
+
5
12
  ### [0.10.10](https://github.com/beauraines/toggl-cli/compare/v0.10.9...v0.10.10) (2023-03-16)
6
13
 
7
14
 
package/cmds/ls.mjs CHANGED
@@ -1,19 +1,32 @@
1
1
  import Client from '../client.js'
2
2
  import { convertUtcTime, formatDuration } from '../utils.js'
3
3
  import dayjs from 'dayjs'
4
+ import debugClient from 'debug'
5
+ import Table from 'cli-table3'
4
6
 
5
- export const command = 'ls'
6
- export const desc = 'Lists time entries'
7
+ const debug = debugClient('toggl-cli-ls')
7
8
 
8
- export const builder = {
9
+ export const command = 'ls [searchStrings...]'
10
+ export const desc = 'Lists recent time entries. Defaults to the last 14 days.'
9
11
 
12
+ export const builder = {
13
+ d: { alias: ['days'], describe: 'The number of days to return.', type: 'number', demandOption: false, default: 14 }
10
14
  }
11
15
 
12
16
  export const handler = async function (argv) {
17
+ debug(argv)
13
18
  const client = Client()
14
- // TODO update these dates
15
- const timeEntries = await client.timeEntries.list({start_date:dayjs().subtract(14,'days').toISOString(),end_date:dayjs().toISOString()});
16
-
19
+ const days = argv.days
20
+ let timeEntries = await client.timeEntries.list({
21
+ start_date: dayjs().subtract(days, 'days').startOf('day').toISOString(),
22
+ end_date: dayjs().toISOString()
23
+ })
24
+ timeEntries.sort((a, b) => (a.start > b.start) ? 1 : -1)
25
+ if (argv.searchStrings) {
26
+ const searchString = argv.searchStrings.join(' ')
27
+ debug(searchString)
28
+ timeEntries = timeEntries.filter(x => x.description.includes(searchString))
29
+ }
17
30
  const report = []
18
31
  timeEntries.forEach(element => {
19
32
  report.push(
@@ -26,5 +39,12 @@ export const handler = async function (argv) {
26
39
  )
27
40
  })
28
41
 
29
- console.table(report, ['description', 'start', 'stop', 'duration'])
42
+ const table = new Table({
43
+ head: ['description', 'start', 'stop', 'duration']
44
+ })
45
+ for (const entry of report) {
46
+ table.push([entry.description, entry.start, entry.stop, entry.duration])
47
+ }
48
+ console.log(table.toString())
49
+ // console.table(report, ['description', 'start', 'stop', 'duration'])
30
50
  }
package/cmds/ls.test.js CHANGED
@@ -1,6 +1,6 @@
1
- describe('ls command',() => {
2
- it.todo('should get tasks for the last 14 days')
3
- // get time entries
4
- // sort them
5
- // check that the earliest is within 14 days
6
- })
1
+ describe('ls command', () => {
2
+ it.todo('should get tasks for the last 14 days')
3
+ // get time entries
4
+ // sort them
5
+ // check that the earliest is within 14 days
6
+ })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beauraines/toggl-cli",
3
- "version": "0.10.10",
3
+ "version": "0.10.11",
4
4
  "description": "",
5
5
  "main": "cli.js",
6
6
  "bin": {