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

Fix Issue #16 - Change openpomodoro client init #24

Closed
wants to merge 2 commits into from

Conversation

hugobally
Copy link

Fix for #16

The --directory flag does not work, all commands use the default ~/.pomodoro directory even when the flag is provided. With the current code, directoryFlag is always an empty string when passed to the openpomodoro.NewClient function because the flag has not been parsed yet at this time.

Moving to the PersistentPreRun hook ensures that all commands will initialize the client with the correct flag value.

Tested on ArchLinux but I don´t think the issue is platform dependent.

Co-authored-by: hugobally hugobally@users.noreply.github.com

The --directory flag does not work, all commands use the default
`~/.pomodoro` directory even when the flag is provided.
With the current code, `directoryFlag` is always an empty string when
passed to the openpomodoro.NewClient function because the flag has not
been parsed yet at this time.
Moving to the PersistentPreRun hook ensures that all commands will
initialize the client with the correct flag value.

Co-authored-by: hugobally <hugobally@users.noreply.github.com>
var (
client *openpomodoro.Client
settings *openpomodoro.Settings
settings = &openpomodoro.DefaultSettings
Copy link
Author

Choose a reason for hiding this comment

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

Since the settings var is not initalized during init() anymore, we need to load it with the default settings otherwise the start command will segfault by trying to access settings on init. (see start.go:31)

@hugobally hugobally closed this Jun 21, 2023
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.

None yet

1 participant