Skip to content

Support 'login-items' as a first-class citizen of the CLI #19744

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vraravam
Copy link

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

  1. First cut of moving login_item from under the uninstall block to the top-level
  2. Fix issues found when running brew update and brew upgrade
  3. Incorporate login_items into info command output (not yet verified)
  4. added login_items option for reinstall command

@vraravam vraravam force-pushed the login-item branch 17 times, most recently from c97b261 to eaba8a8 Compare April 12, 2025 09:42
@vraravam
Copy link
Author

Could someone please help? I am not sure if I am going in the right direction or not. Would love to get some feedback. This PR is trying to solve the #19333 ticket.

@vraravam vraravam marked this pull request as draft April 12, 2025 10:07
@vraravam vraravam force-pushed the login-item branch 4 times, most recently from 7db01f2 to ca5e83a Compare April 13, 2025 00:50
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

@vraravam Looks good so far! Anything specific you need help with?

@vraravam
Copy link
Author

vraravam commented Apr 14, 2025

@vraravam Looks good so far! Anything specific you need help with?

Thanks @MikeMcQuaid - I am first trying to cover all scenarios/commands from the CLI perspective, and finally will proceed to the actual implementation of the osascript calls. Hope that's fine with you?

Also, I'm trying to ensure that all code that I write have tests - if I miss something (since this is my first time contributing to this codebase, i don't know the contributing guidelines/rules), please do point me in that direction as well.

Based on the CLI commands, do you recon that I am missing any? I have tried with install, reinstall and uninstall.

@MikeMcQuaid
Copy link
Member

@vraravam Sounds good to me! When CI is 🟢 let us know and we can give this a more thorough review. CC @homebrew/cask folks for any thoughts before that, too.

homepage "https://brew.sh/"

app "Caffeine.app"
login_items "Caffeine.app"
Copy link
Member

Choose a reason for hiding this comment

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

I think the dsl here should be login_item, and repeated if there are multiple.
This will keep it consistent with the other artifacts, that aren't pluralised.

Copy link
Author

Choose a reason for hiding this comment

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

do you mean like how multiple language blocks are supported in the DSL?

Copy link
Member

Choose a reason for hiding this comment

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

I'm referring to other artifacts such as app, binary, artifact, font, qlplugin, etc..

Copy link
Author

Choose a reason for hiding this comment

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

If we look at the everything.rb DSL, there are other stanzas that are pluralized as well maybe?

Copy link
Member

Choose a reason for hiding this comment

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

All of the artifact stanzas (which I think a login item will most closely relate to) are not pluralised.


suite
app
pkg
installer
binary
manpage
colorpicker
dictionary
font
input_method
internet_plugin
keyboard_layout
prefpane
qlplugin
mdimporter
screen_saver
service
audio_unit_plugin
vst_plugin
vst3_plugin

For context, where multiple items doc the same type are allowed and provided the stanza is repeated rather than passing an array to the stanza.

@@ -13,6 +13,7 @@
==> Downloading file:.*caffeine.zip
Already downloaded: .*--caffeine.zip
==> Uninstalling Cask local-caffeine
==> Skipping processing of login_items
Copy link
Member

Choose a reason for hiding this comment

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

I have a concern that there may be side effects of skipping the uninstallation of login_items.
I understand having the option to automatically register a login_item, but is the idea here to be able to skip uninstalling them? The reason we generally aim to remove as much as possible with brew uninstall (which also runs with brew upgrade) is to not leave things behind that aren't connected to the application anymore.

What happens if the login_item changes between versions?

Copy link
Author

Choose a reason for hiding this comment

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

Agree - I was also facing the same conundrum. This is predominantly for the usecase where the user has chosen to not uninstall by using --no-login-items CLI switch. By default, the registered login items will be uninstalled (I think that's how I have coded it?)

@vraravam vraravam force-pushed the login-item branch 3 times, most recently from 7c0818a to 62cc3ed Compare April 24, 2025 01:56
@vraravam
Copy link
Author

Would love some help in debugging the broken tests. can someone please point me in the general direction of what's wrong?

@vraravam vraravam force-pushed the login-item branch 3 times, most recently from 6d7154b to 1bbc19f Compare May 2, 2025 08:14
@vraravam vraravam force-pushed the login-item branch 4 times, most recently from 2acda6f to 450f732 Compare May 13, 2025 02:09
@vraravam vraravam force-pushed the login-item branch 2 times, most recently from 05481ab to 48f7602 Compare May 21, 2025 13:57
@vraravam vraravam force-pushed the login-item branch 4 times, most recently from ec9876b to 2e0b16a Compare June 6, 2025 16:54
@vraravam vraravam force-pushed the login-item branch 3 times, most recently from 741c696 to 58cfc5c Compare June 14, 2025 11:07
@vraravam vraravam force-pushed the login-item branch 3 times, most recently from 436f85f to 8deaad1 Compare August 1, 2025 07:04
…the top-level

Fix issues found when running brew cli commands (upgrade, update, install)
Incorporate 'login_items' into 'info' command output (not yet verified)
Incorporate 'login_items' option for 'reinstall' command

WIP: Adding placeholder for using osascript to register/unregister login items
Mark for deprecation
Trying to fix broken unit test
Fix ruby version
@bevanjkay
Copy link
Member

@vraravam I can see that you've been chipping away at this PR, and just wanted to ask an additional query here before it goes too deep. I personally feel that the login_item declaration may be more suitable to be considered an "artifact" (defined as "something to install") rather than setting it up as a separate DSL itself. Unless there is a specific reason you haven't gone down this route?

@vraravam
Copy link
Author

vraravam commented Aug 11, 2025

@vraravam I can see that you've been chipping away at this PR, and just wanted to ask an additional query here before it goes too deep. I personally feel that the login_item declaration may be more suitable to be considered an "artifact" (defined as "something to install") rather than setting it up as a separate DSL itself. Unless there is a specific reason you haven't gone down this route?

hi @bevanjkay - The only reason I went this route is that login_item was already defined as a nested item(?) under the uninstall stanza/DSL. If I changed it to an artifact, then there can be recipes where an artifact does not necessarily translate to being a login item. The simplest change that I could see was to elevate login_item from under uninstall to being at the top-level (ie sibling) of uninstall.

btw - I have actually stalled, and would appreciate some help from the community on this PR. I plan to restart and catch up (logically) with code patterns that I had missed (just did rebases till now in the past couple of months).

IF someone with more in-depth knowledge could help, that would be really appreciated.

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.

4 participants