laughedelic / brew-completions

🍺Fish shell completions for Homebrew
Other
49 stars 4 forks source link

Completions no longer work for `brew cask install` #4

Closed lwolfsonkin closed 6 years ago

lwolfsonkin commented 6 years ago

brew was updated deprecating brew cask search, causing annoying error message after every initiation of autocomplete, and the new output of brew search has a separate section for normal formulae and casks.

$ brew search fire
==> Formulae
brewsci/science/arrayfire                            firebase-cli                                         nifi-registry

==> Casks
firealpaca      firebase-admin  firebird-emu    firefox         firestormos     firestr         firetask        mediafire       multifirefox    truefire

3 things should happen:

  1. We should use brew search instead of brew cask search
  2. We should parse the output differently to get just the casks.
  3. For normal brew install we should probably update the output parsing of brew search, though it seems to work fine currently.
laughedelic commented 6 years ago

Hi @lwolfsonkin. Thanks for the report and analysis. I'll look into this when I have some time. Let me know if you're willing to fix it yourself.

laughedelic commented 6 years ago

I think this is blocked now, see https://github.com/Homebrew/brew/issues/4254. brew search just doesn't output casks and I don't see a way to list casks with this change.

peterlobster commented 6 years ago

@laughedelic @lwolfsonkin Considering that brew cask search is going to be deprecated in 10 days (09/30/2018), could perhaps this commit changes things?

Readd functionality to list all casks. #4372

lwolfsonkin commented 6 years ago

@peterlobster: I think theoretically it should, but when I tried to use it, it didn't work for me:

$ brew search --casks sky
==> Formulae
darksky-weather

==> Casks
endlesssky                kinsky                    skyfonts                  skype βœ”                   skype-for-business        skypewebplugin

If it were working properly, there wouldn't be formulae there.

Also for reference:

$ brew --version
Homebrew 1.7.4-58-gbde49f5
Homebrew/homebrew-core (git revision a216b; last commit 2018-09-15)
Homebrew/homebrew-cask (git revision dc49a1; last commit 2018-09-15)

Does it work for you?

peterlobster commented 6 years ago

@lwolfsonkin It does...

brew search sublime --cask                                                            
==> Casks
sublime                                                                homebrew/cask-versions/sublime-text-dev
sublime-text βœ”                                                         homebrew/cask-versions/sublime-text2

@laughedelic Maybe a short term solution would be just to disable the tab completion for brew cask search. You shouldn't be using that anyways. That said, maybe you could up the readme to reflect the change in Homebrew.

lwolfsonkin commented 6 years ago

@peterlobster: I would have to disagree with you here. My understanding of the current functionality of brew search is that, unadorned, it returns formulae and casked, and when given the --casks flag, it should only return casks. You were lucky in this instance because there are no forumulae containing sublime. If you choose to search something that contains formulae and casks, such as docker:

$brew search docker
==> Formulae
docker                          docker-compose                  docker-gen                      docker-machine-driver-hyperkit  docker-machine-parallels
docker-clean                    docker-compose-completion       docker-ls                       docker-machine-driver-vultr     docker-squash
docker-cloud                    docker-credential-helper        docker-machine                  docker-machine-driver-xhyve     docker-swarm
docker-completion βœ”             docker-credential-helper-ecr    docker-machine-completion       docker-machine-nfs              docker2aci

==> Casks
docker βœ”                                             docker-toolbox                                       homebrew/cask-versions/docker-edge

and with the --casks flag:

$brew search --casks docker
==> Formulae
docker                          docker-compose                  docker-gen                      docker-machine-driver-hyperkit  docker-machine-parallels
docker-clean                    docker-compose-completion       docker-ls                       docker-machine-driver-vultr     docker-squash
docker-cloud                    docker-credential-helper        docker-machine                  docker-machine-driver-xhyve     docker-swarm
docker-completion βœ”             docker-credential-helper-ecr    docker-machine-completion       docker-machine-nfs              docker2aci

==> Casks
docker βœ”                                             docker-toolbox                                       homebrew/cask-versions/docker-edge

So, brew does not currently seem to be working according to the new description.

lwolfsonkin commented 6 years ago

UPDATE:

Sorry, I think that I just looked at the documentation, and the documentation is confusing, but does what it says:

In the search documentation, it claims that brew search should return all local formulae, brew search --casks should return all local casks, and brew search [--desc] (<text>|/<text>/) will search online for all casks and formulae. So, essentially, if you provide a text input, regardless of whether --casks is or isn't provided, it will search casks and formulae online.

@laughedelic: I'm assuming this is in contrast to how you were parsing the output of brew cask search previously because I assume if the user typed brew cask info bl, the completion searched brew cask search bl to come up with completions. But now, you would just brew search --casks and pipe to grep bl or something along those lines.

peterlobster commented 6 years ago

@lwolfsonkin You are correct.

@lwolfsonkin @laughedelic You second point in your post, is a excellent idea. The normal 'brew search `search completion function is working fine. Maybe just need to modify it a little bit. I'd offer to make the pull request to implement your idea but I really don't have time right now. I might be able to do it later (like maybe next week), if you guys don't have the time to make the changes.

lwolfsonkin commented 6 years ago

I skimmed through the code, and it seems that the change required is a really simple one-liner. Just swap in brew search --casks. I'm not at my computer right now, but that's all the change should require.

peterlobster commented 6 years ago

@lwolfsonkin I'm assuming you're referring to like 195.

laughedelic commented 6 years ago

Hi guys, thanks for the discussion and the fix from @lwolfsonkin πŸ‘ It seems to work as expected, although it's kind of slow (probably it was the same before), but caching could help here (see #1).