@beauraines/toggl-cli 0.10.9 → 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.
- package/.github/workflows/main.yml +1 -1
- package/CHANGELOG.md +14 -0
- package/cmds/edit.mjs +5 -2
- package/cmds/ls.mjs +27 -7
- package/cmds/ls.test.js +6 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
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
|
+
|
|
12
|
+
### [0.10.10](https://github.com/beauraines/toggl-cli/compare/v0.10.9...v0.10.10) (2023-03-16)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* edit command is throwing an error ([#50](https://github.com/beauraines/toggl-cli/issues/50)) ([794feab](https://github.com/beauraines/toggl-cli/commit/794feab35dae4eb8b79ec4ae1749024bb4f05c72)), closes [#49](https://github.com/beauraines/toggl-cli/issues/49)
|
|
18
|
+
|
|
5
19
|
### [0.10.9](https://github.com/beauraines/toggl-cli/compare/v0.10.7...v0.10.9) (2023-03-13)
|
|
6
20
|
|
|
7
21
|
|
package/cmds/edit.mjs
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
+
/* eslint-disable no-unused-expressions */
|
|
1
2
|
import Client from '../client.js'
|
|
2
3
|
import { defaultWorkspaceId, getProjectByName, getProjectById, appName, displayTimeEntry } from '../utils.js'
|
|
3
4
|
import dayjs from 'dayjs'
|
|
5
|
+
import debugClient from 'debug'
|
|
4
6
|
import utc from 'dayjs/plugin/utc.js'
|
|
5
7
|
import timezone from 'dayjs/plugin/timezone.js'
|
|
6
8
|
import yargs from 'yargs'
|
|
7
9
|
dayjs.extend(utc)
|
|
8
10
|
dayjs.extend(timezone)
|
|
9
11
|
|
|
12
|
+
const debug = debugClient('rtm-cli-edit');
|
|
13
|
+
|
|
10
14
|
export const command = 'edit'
|
|
11
15
|
// FIXME editing not working
|
|
12
|
-
export const desc =
|
|
13
|
-
`and the time must be parsable by dayjs, e.g. 4:50PM or '12:00 AM'.`
|
|
16
|
+
export const desc = 'Edits the current running time entry. Only updating the time is supported and the time must be parsable by dayjs, e.g. 4:50PM or \'12:00 AM\'.'
|
|
14
17
|
|
|
15
18
|
export const builder = {
|
|
16
19
|
d: { alias: ['description'], describe: 'Time entry name', type: 'string:' },
|
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
|
-
|
|
6
|
-
export const desc = 'Lists time entries'
|
|
7
|
+
const debug = debugClient('toggl-cli-ls')
|
|
7
8
|
|
|
8
|
-
export const
|
|
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
|
-
|
|
15
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
+
})
|