Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add time entry, include start with create #165

Merged
merged 6 commits into from
May 25, 2024

Conversation

benthayer
Copy link
Contributor

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

@beauraines beauraines self-assigned this May 21, 2024
@beauraines
Copy link
Owner

@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.

@benthayer
Copy link
Contributor Author

@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>'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for moving this here, this really should have been available for reuse.

@beauraines beauraines merged commit d73f181 into beauraines:main May 25, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants