aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib/hbc/cli/home.rb
blob: 009bc1e3e586ace10a692e7e2eedb98c7196cc89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module Hbc
  class CLI
    class Home < AbstractCommand
      def run
        casks = args.map(&CaskLoader.public_method(:load))

        if casks.empty?
          odebug "Opening project homepage"
          self.class.open_url "https://caskroom.github.io/"
        else
          casks.each do |cask|
            odebug "Opening homepage for Cask #{cask}"
            self.class.open_url cask.homepage
          end
        end
      end

      def self.open_url(url)
        SystemCommand.run!(OS::PATH_OPEN, args: ["--", url])
      end

      def self.help
        "opens the homepage of the given Cask"
      end
    end
  end
end