MacOS – How to query a particular field of brew cask/ formula info

command linehomebrewjsonmacos

Homebrew version on my Mac:

Homebrew 2.5.0-84-g9e697bd

Take github (Cask for GitHub Desktop) for example, this is the cask file located in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/Casks/github.rb:

cask "github" do
  version "2.5.5-f57dc10d"
  sha256 "fe39c280c746b66d13dbcc5acfeb946f77b680954ecda2bf29a560a98a9d2638"

  # githubusercontent.com/ was verified as official when first introduced to the cask
  url "https://desktop.githubusercontent.com/releases/#{version}/GitHubDesktop.zip"
  appcast "https://github.com/desktop/desktop/releases.atom"
  name "GitHub Desktop"
  desc "Desktop client for GitHub repositories"
  homepage "https://desktop.github.com/"

  auto_updates true

  app "GitHub Desktop.app"
  binary "#{appdir}/GitHub Desktop.app/Contents/Resources/app/static/github.sh", target: "github"

  zap trash: [
    "~/Library/Application Support/GitHub Desktop",
    "~/Library/Application Support/com.github.GitHubClient",
    "~/Library/Application Support/com.github.GitHubClient.ShipIt",
    "~/Library/Application Support/ShipIt_stderr.log",
    "~/Library/Application Support/ShipIt_stdout.log",
    "~/Library/Application Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.ApplicationRecentDocuments/com.github.GitHubClient.sfl*",
    "~/Library/Caches/com.github.GitHubClient",
    "~/Library/Caches/com.github.GitHubClient.ShipIt",
    "~/Library/Preferences/com.github.GitHubClient.helper.plist",
    "~/Library/Preferences/com.github.GitHubClient.plist",
    "~/Library/Preferences/ByHost/com.github.GitHubClient.ShipIt.*.plist",
    "~/Library/Logs/GitHub Desktop",
  ],
      rmdir: "~/.config/git"
end

The Cask file has a desc field, and it's value is Desktop client for GitHub repositories.

However, when I do brew search --desc github or brew search --cask --desc github, I only get github: GitHub Desktop, the desc field isn't included.

Sometimes the desc field provides valuable information about a cask. So I wonder if there's a way to make desc included when doing brew search --desc for casks? Thanks!

Best Answer

https://docs.brew.sh/Manpage#cask-command-options-cask

brew cask info github

should work.

--desc is not listed as a valid option for cask.


To specifically check a field in the JSON file /api/cask/github.json (JSON API), use the info command with --json flag and use jq to get the values of a particular field.

While you may find a better way to do it by reading the manual, here's what will work, at least.

brew info --json=v1 github | jq "map(.|.desc)"