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



212
213
214
215
# File 'brew/Library/Homebrew/cask/cmd.rb', line 212

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

Instance Method Details

#_help_for(klass) ⇒ Object



256
257
258
# File 'brew/Library/Homebrew/cask/cmd.rb', line 256

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

#helpObject



252
253
254
# File 'brew/Library/Homebrew/cask/cmd.rb', line 252

def help
  ""
end

#purposeObject



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

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

  EOS
end

#runObject

Raises:

  • (ArgumentError)


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

def run(*)
  purpose
  usage

  return if @command.nil?

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

    raise ArgumentError, "help does not take arguments." if @args.length
  end

  raise ArgumentError, "Unknown Cask command: #{@command}"
end

#usageObject



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

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