Class: Homebrew::Cmd::OptionsCmd

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

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

#runvoid

This method returns an undefined value.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'cmd/options.rb', line 31

def run
  all = args.eval_all?

  if all
    puts_options(Formula.all(eval_all: args.eval_all?).sort)
  elsif args.installed?
    puts_options(Formula.installed.sort)
  elsif args.command.present?
    cmd_options = Commands.command_options(T.must(args.command))
    odie "Unknown command: #{args.command}" if cmd_options.nil?

    if args.compact?
      puts cmd_options.sort.map(&:first) * " "
    else
      cmd_options.sort.each { |option, desc| puts "#{option}\n\t#{desc}" }
      puts
    end
  elsif args.no_named?
    raise FormulaUnspecifiedError
  else
    puts_options args.named.to_formulae
  end
end