Class: ListTool::App::AddItemCommand
- Inherits:
-
Command
- Object
- Command
- ListTool::App::AddItemCommand
show all
- Defined in:
- lib/list_tool/app/commands/add_item_command.rb
Class Method Summary
collapse
Methods inherited from Command
ensure_existence_of, fail_if_not_an_array, parse_item_number, parse_item_number!, parse_list_number, parse_list_number!, parse_number
Class Method Details
.execute(options, lister) ⇒ Object
22
23
24
25
26
|
# File 'lib/list_tool/app/commands/add_item_command.rb', line 22
def execute options, lister
args = [ options.delete(:text) ]
args << options if options[:list]
raise(ListNotFoundError, 'no list with given number') if lister.add_item(*args).nil?
end
|
.help ⇒ Object
28
29
30
|
# File 'lib/list_tool/app/commands/add_item_command.rb', line 28
def help
" a, add-item TEXT [LIST]\tAdd item with TEXT to given or default list"
end
|
.match?(arg) ⇒ Boolean
7
8
9
|
# File 'lib/list_tool/app/commands/add_item_command.rb', line 7
def match? arg
['a', 'add-item'].include? arg
end
|
.parse(argv) ⇒ Object
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/list_tool/app/commands/add_item_command.rb', line 11
def parse argv
fail_if_not_an_array(argv)
item, list = argv.shift(2)
ensure_existence_of('item text' => item)
out = {text: item}
out[:list] = parse_list_number(list) if list
out
end
|