Class: ListTool::App::AddListCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/list_tool/app/commands/add_list_command.rb

Class Method Summary collapse

Class Method Details

.execute(options, lister) ⇒ Object

Raises:

  • (RuntimeError)


19
20
21
# File 'lib/list_tool/app/commands/add_list_command.rb', line 19

def self.execute options, lister
  raise(RuntimeError, "list creation failed") if lister.add_list(options[:name]).nil?
end

.helpObject



23
24
25
# File 'lib/list_tool/app/commands/add_list_command.rb', line 23

def self.help
  "  al, add-list NAME\t\tCreate list with NAME"
end

.match?(arg) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/list_tool/app/commands/add_list_command.rb', line 6

def self.match? arg
  ['al', 'add-list'].include? arg
end

.parse(argv) ⇒ Object

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
# File 'lib/list_tool/app/commands/add_list_command.rb', line 10

def self.parse argv
  raise ArgumentError, "expected argument to be an array, #{argv.class} given" unless argv.is_a? Array
  name = argv.shift
  raise ArgumentError, 'list name not specified' if name.nil?
  raise ArgumentError, 'name is not a string' unless name.is_a? String

  {name: name}
end