Class: Cask::Cmd::NullCommand

Inherits:
Object
  • Object
show all
Defined in:
brew/Library/Homebrew/cask/cmd.rb

Instance Method Summary collapse

Constructor Details

#initialize(command, *args) ⇒ NullCommand

Returns a new instance of NullCommand



215
216
217
218
# File 'brew/Library/Homebrew/cask/cmd.rb', line 215

def initialize(command, *args)
  @command = command
  @args = args
end

Instance Method Details

#_help_for(klass) ⇒ Object



254
255
256
# File 'brew/Library/Homebrew/cask/cmd.rb', line 254

def _help_for(klass)
  klass.respond_to?(:help) ? klass.help : nil
end

#helpObject



250
251
252
# File 'brew/Library/Homebrew/cask/cmd.rb', line 250

def help
  ""
end

#purposeObject



230
231
232
233
234
235
236
# File 'brew/Library/Homebrew/cask/cmd.rb', line 230

def purpose
  puts <<~EOS
    Homebrew Cask provides a friendly CLI workflow for the administration
    of macOS applications distributed as binaries.

  EOS
end

#run(*_args) ⇒ Object

Raises:

  • (ArgumentError)


220
221
222
223
224
225
226
227
228
# File 'brew/Library/Homebrew/cask/cmd.rb', line 220

def run(*_args)
  purpose
  usage

  return if @command.nil?
  return if @command == "help" && @args.empty?

  raise ArgumentError, "help does not take arguments."
end

#usageObject



238
239
240
241
242
243
244
245
246
247
248
# File 'brew/Library/Homebrew/cask/cmd.rb', line 238

def usage
  max_command_len = Cmd.commands.map(&:length).max

  puts "Commands:\n\n"
  Cmd.command_classes.each do |klass|
    next unless klass.visible

    puts "    #{klass.command_name.ljust(max_command_len)}  #{_help_for(klass)}"
  end
  puts %Q(\nSee also "man brew-cask")
end