Class: ListTool::App::UseCommand
- Inherits:
-
Object
- Object
- ListTool::App::UseCommand
- Defined in:
- lib/list_tool/app/commands/use_command.rb
Class Method Summary collapse
Class Method Details
.execute(options, lister) ⇒ Object
21 22 23 |
# File 'lib/list_tool/app/commands/use_command.rb', line 21 def self.execute , lister raise(ListNotFoundError, 'no list with given number') if lister.set_default_list( [:list] ).nil? end |
.help ⇒ Object
25 26 27 |
# File 'lib/list_tool/app/commands/use_command.rb', line 25 def self.help " u, use LIST\t\t\tSet default list" end |
.match?(arg) ⇒ Boolean
6 7 8 |
# File 'lib/list_tool/app/commands/use_command.rb', line 6 def self.match? arg ['u', 'use'].include? arg end |
.parse(argv) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/list_tool/app/commands/use_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 = argv.shift raise ArgumentError, "list number not specified" if list.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 {list: list} end |