Class: Homebrew::Cmd::Info

Inherits:
AbstractCommand show all
Defined in:
cmd/info.rb

Constant Summary collapse

VALID_DAYS =
%w[30 90 365].freeze
VALID_FORMULA_CATEGORIES =
%w[install install-on-request build-error].freeze
VALID_CATEGORIES =
(VALID_FORMULA_CATEGORIES + %w[cask-install os-version]).freeze

Instance Attribute Summary

Attributes inherited from AbstractCommand

#args

Instance Method Summary collapse

Methods inherited from AbstractCommand

command, command_name, #initialize, parser

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#github_remote_path(remote, path) ⇒ Object



110
111
112
113
114
115
116
# File 'cmd/info.rb', line 110

def github_remote_path(remote, path)
  if remote =~ %r{^(?:https?://|git(?:@|://))github\.com[:/](.+)/(.+?)(?:\.git)?$}
    "https://github.com/#{Regexp.last_match(1)}/#{Regexp.last_match(2)}/blob/HEAD/#{path}"
  else
    "#{remote}/#{path}"
  end
end

#runvoid

This method returns an undefined value.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'cmd/info.rb', line 77

def run
  if args.analytics?
    if args.days.present? && VALID_DAYS.exclude?(args.days)
      raise UsageError, "`--days` must be one of #{VALID_DAYS.join(", ")}."
    end

    if args.category.present?
      if args.named.present? && VALID_FORMULA_CATEGORIES.exclude?(args.category)
        raise UsageError,
              "`--category` must be one of #{VALID_FORMULA_CATEGORIES.join(", ")} when querying formulae."
      end

      unless VALID_CATEGORIES.include?(args.category)
        raise UsageError, "`--category` must be one of #{VALID_CATEGORIES.join(", ")}."
      end
    end

    print_analytics
  elsif args.json
    all = args.eval_all?

    print_json(all)
  elsif args.github?
    raise FormulaOrCaskUnspecifiedError if args.no_named?

    exec_browser(*args.named.to_formulae_and_casks.map { |f| github_info(f) })
  elsif args.no_named?
    print_statistics
  else
    print_info
  end
end