Skip to content

tailscale-app: Generate completions for the installed CLI. #223049

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

lgarron
Copy link
Contributor

@lgarron lgarron commented Aug 7, 2025

The tailscale-app cask wraps /Applications/Tailscale.app/Contents/MacOS/Tailscale and places it into the path as tailscale.

This command can generate its own completions. Support for this was added to the headless tailscale formula at Homebrew/homebrew-core#172679

This PR adds the same support to the tailscale-app cask, using the same mechanism.


Important: Do not tick a checkbox if you haven’t performed its action. Honesty is indispensable for a smooth review process.

In the following questions <cask> is the token of the cask you're submitting.

After making any changes to a cask, existing or new, verify:

The `tailscale-app` cask wraps `/Applications/Tailscale.app/Contents/MacOS/Tailscale` and places it into the path as `tailscale`.

This command can generate its own completions. Support for this was added to the headless `tailscale` *formula* at Homebrew/homebrew-core#172679

This PR adds the same support to the `tailscale-app` cask, using the same mechanism.
@lgarron
Copy link
Contributor Author

lgarron commented Aug 7, 2025

  • brew audit --cask --online <cask> is error-free.
  • brew style --fix <cask> reports no offenses.

I'm on cellular internet right now and I don't have a local checkout, so these are impractical to run.

However, brew reinstall tailscale-app on the modified cask successfully installed the completions.

@lgarron lgarron force-pushed the patch-3 branch 2 times, most recently from 9a81fc9 to 45f92ba Compare August 7, 2025 07:49
Copy link
Contributor Author

@lgarron lgarron left a comment

Choose a reason for hiding this comment

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

.

@@ -28,6 +28,10 @@
EOS
end

def install
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The linter wants me to rewrite this to:

define_method(:install)

However, this also causes CI to fail: https://github.com/Homebrew/homebrew-cask/actions/runs/16798346181/job/47573677907

I'm not sure what I'm supposed to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like install is not allowed by the linter, even though it is run by brew install --cask? I'm going to try postflight.

@lgarron
Copy link
Contributor Author

lgarron commented Aug 7, 2025

Okay, I'm at a bit of a loss. It seems that no casks use generate_completions_from_executable(…).

They all use:

  • bash_completion
  • fish_completion
  • zsh_completion

That only leaves out powershell from the completions supported by the tailscale CLI, which I guess is fine given that this cask is for the macOS app?

However, these assume that there is a completion file rather than a completion command whose output provides the completions. I'm not sure what to do.

@oschrenk
Copy link
Contributor

oschrenk commented Aug 7, 2025

Apart from the formula issues, I think you will find that the completion command will fail after a fresh install.

❯ tailscale completion
Error: CLI credentials are not available BadResponse

Even for help you need to be logged in

❯ tailscale --help
Error: CLI credentials are not available BadResponse

So (I'm not a maintainer nor an expert in brew) but I think this will be an issue.

@lgarron
Copy link
Contributor Author

lgarron commented Aug 8, 2025

Apart from the formula issues, I think you will find that the completion command will fail after a fresh install.

Ah, that's really unfortunate if that's the case.

However, I just purged my entire Tailscale install (using AppCleaner and brew uninstall tailscale-app) and ran brew install tailscale-app from scratch. I can't reproduce that error, even though I'm logged out. 🤔

@oschrenk
Copy link
Contributor

oschrenk commented Aug 8, 2025

I think it was because I had another VPN running. Once I stopped that one, I was able issue CLI command.

Comment on lines +31 to +33
install do
generate_completions_from_executable("#{appdir}/Tailscale.app/Contents/MacOS/Tailscale", "completion")
end
Copy link
Member

Choose a reason for hiding this comment

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

@lgarron Thanks for trying to get this work, but I don't believe it is possible to generate completions in this way for a Cask, only with a Formula. The completion stanzas available only install the completions from an already built file.

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.

3 participants