Class: ListTool::App::RenameListCommand
- Inherits:
-
Object
- Object
- ListTool::App::RenameListCommand
- Defined in:
- lib/list_tool/app/commands/rename_list_command.rb
Class Method Summary collapse
Class Method Details
.execute(options, lister) ⇒ Object
22 23 24 25 |
# File 'lib/list_tool/app/commands/rename_list_command.rb', line 22 def self.execute , lister args = [ [:list], [:name] ] raise(ListNotFoundError, 'no list with given number') if lister.rename_list(*args).nil? end |
.help ⇒ Object
27 28 29 |
# File 'lib/list_tool/app/commands/rename_list_command.rb', line 27 def self.help " rl, rename-list LIST, NAME\tSet LIST name to NAME" end |
.match?(arg) ⇒ Boolean
6 7 8 |
# File 'lib/list_tool/app/commands/rename_list_command.rb', line 6 def self.match? arg ['rl', 'rename-list'].include? arg end |
.parse(argv) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/list_tool/app/commands/rename_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 list, name = argv.shift(2) raise ArgumentError, 'list number not specified' if list.nil? raise ArgumentError, 'new name not specified' if name.nil? list = Integer(list) - 1 rescue raise(ArgumentError, 'list number must be an integer') raise ArgumentError, "list number can't be less than 1" if list < 0 {name: name, list: list} end |