Class: Bl::Commands::Type

Inherits:
Bl::Command show all
Defined in:
lib/bl/commands/type.rb

Instance Method Summary collapse

Methods included from Printer

print_response, printable_issues

Methods included from Requestable

client, formatter, request

Constructor Details

#initializeType

Returns a new instance of Type.



4
5
6
7
8
# File 'lib/bl/commands/type.rb', line 4

def initialize(*)
  @config = Bl::Config.instance
  @url = "projects/#{@config[:project_key]}/issueTypes"
  super
end

Instance Method Details

#add(*names) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/bl/commands/type.rb', line 19

def add(*names)
  names.each do |name|
    res = request(:post, @url, name: name, color: options[:color])
    puts 'type added'
    print_response(res, :type)
  end
end

#colorsObject



49
50
51
52
53
54
# File 'lib/bl/commands/type.rb', line 49

def colors
  puts 'colors:'
  TYPE_COLORS.each do |color|
    puts Paint[color, '#ffffff', color]
  end
end

#delete(*ids) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/bl/commands/type.rb', line 40

def delete(*ids)
  ids.each do |id|
    res = request(:delete, "#{@url}/#{id}", delete_class_options(options))
    puts 'type deleted'
    print_response(res, :type)
  end
end

#listObject



11
12
13
14
15
# File 'lib/bl/commands/type.rb', line 11

def list
  res = request(:get, @url)
  puts 'types:'
  print_response(res, :type)
end

#update(*ids) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/bl/commands/type.rb', line 30

def update(*ids)
  ids.each do |id|
    res = request(:patch, "#{@url}/#{id}", delete_class_options(options))
    puts 'type updated'
    print_response(res, :type)
  end
end