@beauraines/toggl-cli 0.10.20 → 0.10.22
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/CHANGELOG.md +20 -0
- package/cmds/edit.mjs +8 -3
- package/cmds/ls.mjs +17 -6
- package/package.json +1 -1
- package/utils.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
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.22](https://github.com/beauraines/toggl-cli/compare/v0.10.21...v0.10.22) (2023-07-08)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **ls:** Adds today option ([adc9779](https://github.com/beauraines/toggl-cli/commit/adc977912859d599a2a02c53d3c6529b52ecc9b4))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **edit:** updates duration when editing a running entry ([60a6d47](https://github.com/beauraines/toggl-cli/commit/60a6d474e83379c69861e063afc48b74f88473a8))
|
|
16
|
+
* **utils:** properly handles null time in displayTimeEntry ([0476db0](https://github.com/beauraines/toggl-cli/commit/0476db098c72f2997d916149dfdeb4f50d7a43ce))
|
|
17
|
+
|
|
18
|
+
### [0.10.21](https://github.com/beauraines/toggl-cli/compare/v0.10.20...v0.10.21) (2023-07-08)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* **ls:** adds details to time entry listing ([7ad05c7](https://github.com/beauraines/toggl-cli/commit/7ad05c797729bbaa34dc2a6be99397e1a01c24a2)), closes [#72](https://github.com/beauraines/toggl-cli/issues/72)
|
|
24
|
+
|
|
5
25
|
### [0.10.20](https://github.com/beauraines/toggl-cli/compare/v0.10.19...v0.10.20) (2023-07-08)
|
|
6
26
|
|
|
7
27
|
### [0.10.19](https://github.com/beauraines/toggl-cli/compare/v0.10.18...v0.10.19) (2023-07-08)
|
package/cmds/edit.mjs
CHANGED
|
@@ -12,7 +12,6 @@ dayjs.extend(timezone)
|
|
|
12
12
|
const debug = debugClient('toggl-cli-edit');
|
|
13
13
|
|
|
14
14
|
export const command = 'edit'
|
|
15
|
-
// FIXME editing not working
|
|
16
15
|
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\'.'
|
|
17
16
|
|
|
18
17
|
export const builder = {
|
|
@@ -30,7 +29,7 @@ export const handler = async function (argv) {
|
|
|
30
29
|
}
|
|
31
30
|
const client = new Client()
|
|
32
31
|
const currentTimeEntry = await client.timeEntries.current()
|
|
33
|
-
|
|
32
|
+
debug(currentTimeEntry)
|
|
34
33
|
const params = {}
|
|
35
34
|
|
|
36
35
|
params.workspace_id = +defaultWorkspaceId
|
|
@@ -59,10 +58,16 @@ export const handler = async function (argv) {
|
|
|
59
58
|
}
|
|
60
59
|
|
|
61
60
|
params.created_with = appName
|
|
62
|
-
params.at = dayjs().toISOString()
|
|
63
61
|
project ? params.project_id = +project.id : undefined
|
|
64
62
|
startTime ? params.start = startTime.toISOString() : undefined
|
|
65
63
|
endTime ? params.stop = endTime.toISOString() : undefined
|
|
64
|
+
if (startTime || endTime) {
|
|
65
|
+
const startTimeUnix = (startTime || dayjs(currentTimeEntry.start)).unix()
|
|
66
|
+
const endTimeUnix = (endTime || dayjs(currentTimeEntry.end) || dayjs()).unix()
|
|
67
|
+
let duration = endTimeUnix - startTimeUnix
|
|
68
|
+
duration = endTime ? duration : startTimeUnix * -1
|
|
69
|
+
params.duration = duration
|
|
70
|
+
}
|
|
66
71
|
argv.description ? params.description = argv.description : undefined
|
|
67
72
|
debug(params)
|
|
68
73
|
const timeEntry = await client.timeEntries.update(currentTimeEntry.id, params)
|
package/cmds/ls.mjs
CHANGED
|
@@ -10,13 +10,14 @@ export const command = 'ls [searchStrings...]'
|
|
|
10
10
|
export const desc = 'Lists recent time entries. Defaults to the last 14 days.'
|
|
11
11
|
|
|
12
12
|
export const builder = {
|
|
13
|
-
d: { alias: ['days'], describe: 'The number of days to return.', type: 'number', demandOption: false, default: 14 }
|
|
13
|
+
d: { alias: ['days'], describe: 'The number of days to return. Ignored if --today provided', type: 'number', demandOption: false, default: 14 },
|
|
14
|
+
today: {describe: 'Only returns today\'s time entries. Overrides --days.', type: 'boolean', demandOption: false}
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export const handler = async function (argv) {
|
|
17
18
|
debug(argv)
|
|
18
19
|
const client = Client()
|
|
19
|
-
const days = argv.days
|
|
20
|
+
const days = argv.today ? 0 : argv.days
|
|
20
21
|
let timeEntries = await client.timeEntries.list({
|
|
21
22
|
start_date: dayjs().subtract(days, 'days').startOf('day').toISOString(),
|
|
22
23
|
end_date: dayjs().toISOString()
|
|
@@ -27,20 +28,30 @@ export const handler = async function (argv) {
|
|
|
27
28
|
debug(searchString)
|
|
28
29
|
timeEntries = timeEntries.filter(x => x.description.includes(searchString))
|
|
29
30
|
}
|
|
31
|
+
|
|
32
|
+
const workspaces = await client.workspaces.list()
|
|
33
|
+
const workspace = workspaces[0]
|
|
34
|
+
debug('Workspace: ' + workspace.name)
|
|
35
|
+
debug('id: ' + workspace.id)
|
|
36
|
+
const projects = await client.workspaces.projects(workspace.id)
|
|
37
|
+
|
|
30
38
|
const report = []
|
|
31
39
|
timeEntries.forEach(element => {
|
|
32
40
|
report.push(
|
|
33
41
|
{
|
|
34
42
|
description: element.description,
|
|
43
|
+
project: projects.filter(p => p.id == element.project_id)[0]?.name,
|
|
44
|
+
project_id: projects.filter(p => p.id == element.project_id)[0]?.id,
|
|
35
45
|
start: convertUtcTime(element.start),
|
|
36
46
|
stop: convertUtcTime(element.stop),
|
|
37
|
-
duration: formatDuration(element.duration * 1000)
|
|
47
|
+
duration: formatDuration(element.duration * 1000),
|
|
48
|
+
id: element.id
|
|
38
49
|
}
|
|
39
50
|
)
|
|
40
51
|
})
|
|
41
52
|
|
|
42
53
|
const table = new Table({
|
|
43
|
-
head: ['Description', 'Start', 'Stop', 'Duration'],
|
|
54
|
+
head: ['Description', 'Project', 'Start', 'Stop', 'Duration', 'Time Entry ID'],
|
|
44
55
|
chars: { mid: '', 'left-mid': '', 'mid-mid': '', 'right-mid': '' }
|
|
45
56
|
})
|
|
46
57
|
for (let i = 0; i < report.length; i++) {
|
|
@@ -53,9 +64,9 @@ export const handler = async function (argv) {
|
|
|
53
64
|
}
|
|
54
65
|
const entry = report[i]
|
|
55
66
|
if (i === 0) {
|
|
56
|
-
table.push([entry.description, entry.start, entry.stop, entry.duration].map((content) => ({ content, chars })))
|
|
67
|
+
table.push([entry.description, entry.project, entry.start, entry.stop, entry.duration, entry.id].map((content) => ({ content, chars })))
|
|
57
68
|
} else {
|
|
58
|
-
table.push([entry.description, entry.start, entry.stop, entry.duration])
|
|
69
|
+
table.push([entry.description, entry.project, entry.start, entry.stop, entry.duration, entry.id])
|
|
59
70
|
}
|
|
60
71
|
}
|
|
61
72
|
console.log(table.toString())
|
package/package.json
CHANGED
package/utils.js
CHANGED
|
@@ -121,7 +121,7 @@ export const displayTimeEntry = async function (timeEntry) {
|
|
|
121
121
|
|
|
122
122
|
const tz = process.env.TOGGL_TIMEZONE || 'America/New_York'
|
|
123
123
|
const startTimeFormatted = dayjs(timeEntry.start).tz(tz).format('YYYY-MM-DD HH:mm')
|
|
124
|
-
const stopTimeFormatted = dayjs(timeEntry.stop).tz(tz).format('YYYY-MM-DD HH:mm')
|
|
124
|
+
const stopTimeFormatted = timeEntry.stop ? dayjs(timeEntry.stop).tz(tz).format('YYYY-MM-DD HH:mm') : 'Currently Running'
|
|
125
125
|
|
|
126
126
|
console.info(`Start: ${startTimeFormatted}`)
|
|
127
127
|
console.info(`Stop: ${stopTimeFormatted}`) // This will always be blank for the current entry, but will be useful for a time entry
|