Sha256: 843aa3740b32b6dd59229eff8ab9722da08ecfd6b540e2760df5e8b7e3578406

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

module TrelloCli
  module CLI
    module Card
      class Create

        def initialize
          @options = { members: [] }
        end

        def run
          option_parser.parse!

          card        = create_card
          name        = card.attributes[:name]
          description = card.attributes[:description]

          puts "Card Created."
          puts "Name        : #{name}"
          puts "Description : #{description}"
        end

        private

        def create_card
          cc = TrelloCli::Requests::CreateCard.new
          cc.create @options
        end

        def option_parser
          OptionParser.new do |opts|
            opts.banner = "Usage: trello card [create] [options]"

            opts.on("-b", "--board [BOARD]", "Trello Board Id") do |b|
              @options[:board_id] = b
            end

            opts.on("-d", "--description [DESCRIPTION]", "Description Of Card") do |d|
              @options[:description] = d
            end

            opts.on("-l", "--list [LIST]", "List Of Card") do |l|
              @options[:list_id] = l
            end

            opts.on("-m", "--member [MEMBER_NAME]", "Member name to assign to card") do |m|
              @options[:members] << m
            end

            opts.on("-n", "--name [NAME]", "Name Of Card") do |n|
              @options[:name] = n
            end
          end
        end

        def help
          puts option_parser.help
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trello_cli-0.3.0 lib/trello_cli/cli/card/create.rb