Sha256: 67cd64521c0c2285c79022133ae2255ba3a900559890bdbbbf872ed89fc6c69d

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

module TrelloCli
  module CLI
    module Card
      class Move

        def initialize
          @options = {}
        end

        def run
          option_parser.parse!

          result = move_card
          data = { card_id: result["id"],
                   list_id: result["idList"],
                   success: (result["idList"] == @options[:list_id]) }

          puts TrelloCli::Formatters::CardMove.new(data).output @options[:output]
        end

        private

        def move_card
          mc = TrelloCli::Requests::MoveCard.new
          mc.move @options
        end

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

            opts.on("-c", "--card_id [CARD_ID]", "ID of Card") do |c|
              @options[:card_id] = c
            end

            opts.on("-l", "--list_id [LIST_ID]", "New List ID") do |l|
              @options[:list_id] = l
            end

            opts.on("-o", "--output [OUTPUT]", "Output format [json|tsv|legacy]." ) do |o|
              @options[:output] = o
            end
          end
        end

        def help
          puts option_parser.help
        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
trello_cli-0.5.0 lib/trello_cli/cli/card/move.rb
trello_cli-0.4.1 lib/trello_cli/cli/card/move.rb
trello_cli-0.4.0 lib/trello_cli/cli/card/move.rb