class Fuelcell::Action::NotFound

Null Object used to indicate a command has not been found

Public Class Methods

new(cmd_args) click to toggle source
Calls superclass method Fuelcell::Action::Command::new
# File lib/fuelcell/action/not_found.rb, line 5
def initialize(cmd_args)
  super(validate_cmd_args(cmd_args))

  @callable = command_not_found_action
  @usage    = ''
  @desc     = 'command not found command'
end

Public Instance Methods

<<(_cmd) click to toggle source
# File lib/fuelcell/action/not_found.rb, line 34
def <<(_cmd)
end
callable(_value = nil) click to toggle source
# File lib/fuelcell/action/not_found.rb, line 21
def callable(_value = nil)
  @callable
end
command(key, &block) click to toggle source
# File lib/fuelcell/action/not_found.rb, line 25
def command(key, &block)
  cmd = Command.new(key)
  cmd.instance_eval(&block)
  nil
end
desc(_value = nil) click to toggle source
# File lib/fuelcell/action/not_found.rb, line 17
def desc(_value = nil)
  @desc
end
opt(_name, _config = {}) click to toggle source
# File lib/fuelcell/action/not_found.rb, line 31
def opt(_name, _config = {})
end
usage(_value = nil) click to toggle source
# File lib/fuelcell/action/not_found.rb, line 13
def usage(_value = nil)
  @usage
end

Private Instance Methods

command_not_found_action() click to toggle source
# File lib/fuelcell/action/not_found.rb, line 47
def command_not_found_action
  lambda do |_opts, _args, shell|
    shell.error "command #{name} not found"
    return 1
  end
end
validate_cmd_args(args) click to toggle source
# File lib/fuelcell/action/not_found.rb, line 39
def validate_cmd_args(args)
  args = args.is_a?(String) ? [args] : args
  unless args.respond_to?(:join)
    fail ArgumentError, 'cmd_args must implement join'
  end
  args.join(' ')
end