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

Desktop Notifications, the sequel #109

Merged
merged 6 commits into from
Oct 30, 2017
Merged

Conversation

febbraro
Copy link
Member

Disabling it globally is controlled with RIG_SILENCE_NOTIFY env var that is a boolean. It takes 1, t, T, TRUE, true, True for true and 0, f, F, FALSE, false, False for false

@febbraro febbraro added this to the v2.0 milestone Oct 30, 2017
@febbraro febbraro requested review from tekante and grayside October 30, 2017 18:44
Copy link
Contributor

@grayside grayside left a comment

Choose a reason for hiding this comment

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

Overall good stuff. Should the logo be moved to an images directory in case we have other uses for it?

return nil
}

// Success encapsulates the functionality for reporting command success
func (cmd *BaseCommand) Success(message string) error {
if message != "" {
cmd.out.Info.Println(message)
util.NotifySuccess(cmd.context, message)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since a number of our commands do not return cmd.Success(), is the idea that not returning Success() means the command is opting out of notifications? It seems as though we should return success for everything and have a boolean parameter to suppress notifications.

Copy link
Member Author

Choose a reason for hiding this comment

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

They should all be returning cmd.Success now, that was part of the PR to transition to this centralized system. If you dont want a message or notifications you just return "" the empty string.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay. We may want to switch this per my comment later on if we have other things triggered on Success that we don't want commands to opt-out from. That seems fine to happen when such a use case arises.

util/notify.go Outdated
if !isSet {
return true
}
val, err := strconv.ParseBool(env)
Copy link
Contributor

Choose a reason for hiding this comment

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

Oooh, ParseBool. Should this be in our user input util function?

Copy link
Member Author

Choose a reason for hiding this comment

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

doesn't seem like it would need to move there, there is app and use case specific knowledge in this case and just wrapping a core lib function seems like overkill.

util/notify.go Outdated

// shouldNotify returns a boolean if notifications are enabled
func shouldNotify() bool {
env, isSet := os.LookupEnv("RIG_SILENCE_NOTIFY")
Copy link
Contributor

Choose a reason for hiding this comment

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

My sense is that RIG_NOTIFY_SILENCE is a better name, as there is more likely to be other RIG_NOTIFY_* vars than RIG_SILENCE_*

Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be a global parameter, allowing rig --silence

Copy link
Member Author

Choose a reason for hiding this comment

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

Most apps use --quiet but that is generally targeted at log messages, not notifications. I can go either way on a CLI flag for it. Do you feel strongly one way or another?

(I do agree with the name change)

@@ -27,19 +28,25 @@ func (cmd *BaseCommand) Before(c *cli.Context) error {
util.LoggerInit(c.GlobalBool("verbose"))
cmd.out = util.Logger()
cmd.machine = Machine{Name: c.GlobalString("name"), out: util.Logger()}

util.NotifyInit(fmt.Sprintf("Outrigger (rig) %s", c.App.Version))
cmd.context = c
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to stash context? This is begging for a why comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, we need it so Error() and Success() do not need ctx passed in. Could still use a comment to point that out.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

@febbraro
Copy link
Member Author

febbraro commented Oct 30, 2017

w/r/t logo, I think that if the application itself uses it, it should be in an application/code folder, that way any changes are done in a known application space. If we need a logo for more documentation or other purposes, then we can have an additional one in an images/ or assets/ dir.

@febbraro febbraro self-assigned this Oct 30, 2017
@febbraro febbraro merged commit 91abbcc into develop Oct 30, 2017
@febbraro febbraro deleted the feature/desktop-notifications-2 branch October 30, 2017 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants