Add time entry, include start with create#165
Conversation
|
@benthayer I've been traveling and am catching up. This is on my todo list, but it will be a few days before i get back to it. |
All good, no rush. I'm using my local version, so no rush merging this in, just wanted to share my code |
|
|
||
| const debug = debugClient('toggl-cli-add'); | ||
|
|
||
| export const command = 'add <startTime> <endTime> <description>' |
There was a problem hiding this comment.
I think these should be optional using the [] syntax, so that the start, end and description arguments can be used, too.
This will give us more flexibility - I think about adding new entries like "I did xxx from start until end", but it wil work in the "From start to end, I did xxx"
I'll make that change and test - but I'm in the middle of making brunch and I discovered that I can push changes!
There was a problem hiding this comment.
With the change in
this works
DEBUG=toggl-cli-add ./cli.js add -d foo -s 8:30 -e '9:02 AM'
as well as what you had originally
DEBUG=toggl-cli-add ./cli.js add 8:00 '08:33 AM' foo
There was a problem hiding this comment.
Great, glad we have functionality we both like!
Makes the positional `startTime`, `endTime` and `description` optional, so that they can _also_ be specified through cli options
| } | ||
| argv.description ? params.description = argv.description : undefined | ||
| debug(params) | ||
| const timeEntry = await client.timeEntries.create(params) |
There was a problem hiding this comment.
I have a createTimeEntry() in the utils, but it doesn't support creating a time entry with an endTime. I'll open a new issue to extend that function and use it here too. I see that you started with the edit command which does its own interaction with the client. I'm not very good about repeating myself or abstracting methods.
| * @param {string} timeString timelike string e.g. 4:50PM '12:00 AM' etc. | ||
| * @returns {object} dayjs object | ||
| */ | ||
| export function parseTime (timeString) { |
There was a problem hiding this comment.
Thank you for moving this here, this really should have been available for reuse.
Hello again,
I added the functionality to add entries with start/stop time.
Also there was a bug in the parseTime function. I fixed it so that time entries are correct for midnight and then I moved it into the utils file