Completed
Push — master ( 859f44...444e7c )
by Michael
03:10
created

NoSECLI.list()   A

Complexity

Conditions 3

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
c 1
b 0
f 0
dl 0
loc 13
ccs 6
cts 6
cp 1
crap 3
rs 9.4285
1
# frozen_string_literal: true
2
3 1
module NoSE
4 1
  module CLI
5
    # Add a command to list different types of classes available
6 1
    class NoSECLI < Thor
7 1
      desc 'list TYPE', 'list available objects of the given TYPE'
8
9 1
      AVAILABLE_TYPES = %w(backend cost).freeze
10
11 1
      long_desc <<-LONGDESC
12
        `nose list` shows available objects of different types.
13
14
        The following types are currently supported:
15
          #{AVAILABLE_TYPES.join ', '}
16
      LONGDESC
17
18 1
      def list(type)
19 3
        case type
20
        when 'backend'
21 1
          cls = Backend::Backend
22
        when 'cost'
23 1
          cls = Cost::Cost
24
        else
25 1
          fail Thor::UnknownArgumentError,
26
               "Invalid type. Available types are #{AVAILABLE_TYPES.join ', '}"
27
        end
28
29 10
        cls.subclasses.each_value { |c| puts c.subtype_name }
30
      end
31
    end
32
  end
33
end
34