Skip to content

Add --break option to finish subcommand#36

Merged
justincampbell merged 6 commits intomainfrom
add-break-option-to-finish
Sep 24, 2025
Merged

Add --break option to finish subcommand#36
justincampbell merged 6 commits intomainfrom
add-break-option-to-finish

Conversation

@justincampbell
Copy link
Copy Markdown
Member

Summary

• Added a --break flag to the finish command that automatically starts a break after finishing a pomodoro
• The break duration can be specified in minutes (e.g., --break 5 or --break 5m)
• Implemented in two separate commits: first working implementation, then refactored to eliminate code duplication

Test plan

  • Build successfully compiles
  • pomodoro finish --help shows the new --break flag
  • Test pomodoro finish --break 5 starts a 5-minute break after finishing a pomodoro
  • Test default break duration works when just using --break

🤖 Generated with Claude Code

@justincampbell justincampbell force-pushed the add-break-option-to-finish branch 2 times, most recently from 445b568 to 2462e8e Compare September 24, 2025 02:14
Copilot AI review requested due to automatic review settings September 24, 2025 02:14
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds a --break flag to the finish command that automatically starts a break timer after completing a pomodoro. The implementation includes duration parsing that defaults to minutes when no unit is specified, and refactors duplicate code into a shared utility module.

  • Added --break flag to finish command with customizable duration
  • Created shared utility functions for countdown timer and duration parsing
  • Eliminated code duplication between break and finish commands

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
cmd/util.go New utility file containing shared wait and parseDurationMinutes functions
cmd/finish.go Added --break flag implementation and break logic after finishing pomodoro
cmd/break.go Removed duplicate utility functions that were moved to util.go

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

cmd/finish.go Outdated
Comment on lines +43 to +46
if cmd.Flags().Changed("break") {
breakDuration := settings.DefaultBreakDuration

if breakFlag != "" {
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

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

The logic checks both cmd.Flags().Changed(\"break\") and breakFlag != \"\" which creates redundant conditions. When a flag is changed, the value will either be the provided value or empty string. Consider simplifying to just check if the flag was changed and handle the empty string case as the default duration.

Copilot uses AI. Check for mistakes.
justincampbell and others added 5 commits September 24, 2025 09:57
This adds a --break flag to the finish command that allows users to
automatically start a break after finishing a pomodoro. The break
duration can be specified in minutes.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Remove duplicated wait() and parseDurationMinutes() functions from
finish.go and reuse the existing functions from break.go. This
eliminates code duplication while maintaining the same functionality.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Moved wait() and parseDurationMinutes() functions from break.go
to a new util.go file to better organize shared functionality
used by both break and finish commands.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Fixed logic error where breakFlag was checked twice unnecessarily.
Now properly parses the break duration when --break flag is provided.

Usage: `pomodoro finish --break 5` (not `pomodoro finish 5`)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…alue

When using `pomodoro finish --break` without specifying a duration,
the command now properly uses the user's DefaultBreakDuration setting
instead of requiring a value. This allows users to customize their
default break duration in settings.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@justincampbell justincampbell force-pushed the add-break-option-to-finish branch from 2462e8e to 1e0ae65 Compare September 24, 2025 13:57
- Add bats tests for --break flag with and without duration
- Add Go unit tests for parseDurationMinutes using testify
- Fix missing trailing newline in cmd/util.go
- Add short flag -b for --break option
- Use TrimSpace to properly handle NoOptDefVal

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 24, 2025 14:25
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

}

command.Flags().StringVarP(&breakFlag, "break", "b", "", "take a break after finishing (duration in minutes)")
command.Flags().Lookup("break").NoOptDefVal = " "
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

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

Using a space character as the NoOptDefVal is unclear and could be confusing. Consider using an empty string or a more explicit default value like "default" to make the intent clearer.

Suggested change
command.Flags().Lookup("break").NoOptDefVal = " "
command.Flags().Lookup("break").NoOptDefVal = ""

Copilot uses AI. Check for mistakes.
Comment on lines +48 to +49
trimmedFlag := strings.TrimSpace(breakFlag)
if trimmedFlag != "" {
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

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

The logic for handling the space character NoOptDefVal is indirect and hard to follow. Since you're trimming spaces and checking for emptiness, the space character from NoOptDefVal will always result in using the default duration, making this approach unnecessarily complex.

Copilot uses AI. Check for mistakes.
@justincampbell justincampbell merged commit 2eeb771 into main Sep 24, 2025
2 checks passed
@justincampbell justincampbell deleted the add-break-option-to-finish branch September 24, 2025 14:26
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