@beauraines/toggl-cli 0.10.21 → 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 CHANGED
@@ -2,6 +2,19 @@
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
+
5
18
  ### [0.10.21](https://github.com/beauraines/toggl-cli/compare/v0.10.20...v0.10.21) (2023-07-08)
6
19
 
7
20
 
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()
@@ -36,7 +37,6 @@ export const handler = async function (argv) {
36
37
 
37
38
  const report = []
38
39
  timeEntries.forEach(element => {
39
- console.log(element)
40
40
  report.push(
41
41
  {
42
42
  description: element.description,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beauraines/toggl-cli",
3
- "version": "0.10.21",
3
+ "version": "0.10.22",
4
4
  "description": "",
5
5
  "main": "cli.js",
6
6
  "bin": {
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