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



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

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

Instance Method Details

#_help_for(klass) ⇒ Object



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

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

#helpObject



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

def help
  ""
end

#purposeObject



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

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)


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

def run(*_args)
  purpose
  usage

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

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

#usageObject



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

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