Sha256: 301b40f7324b789571c23f8e12e554290e8b74142a3fe5afe7d18a6cc84dc751

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 KB

Contents

Tr3llo::Utils.require_directory(File.dirname(__FILE__) + "/list/*.rb")

module Tr3llo
  module Command
    module List
      extend self

      def execute(subcommand, args)
        case subcommand
        when "list"
          board = Application.fetch_board!()

          Command::List::List.execute(board[:id])
        when "add"
          board = Application.fetch_board!()

          Command::List::Add.execute(board[:id])
        when "cards"
          list_key, = args
          Utils.assert_string!(list_key, "list key is missing")

          Command::List::Cards.execute(list_key)
        when "archive-cards"
          list_key, = args
          Utils.assert_string!(list_key, "list key is missing")

          Command::List::ArchiveCards.execute(list_key)
        else
          handle_invalid_subcommand(subcommand, args)
        end
      rescue InvalidArgumentError => exception
        Command::List::Invalid.execute(exception.message)
      rescue InvalidCommandError => exception
        Command::List::Invalid.execute(exception.message)
      rescue BoardNotSelectedError => exception
        Command::List::Invalid.execute(exception.message)
      end

      private

      def handle_invalid_subcommand(subcommand, _args)
        case subcommand
        when String
          raise InvalidCommandError.new("#{subcommand.inspect} is not a valid command")
        when NilClass
          raise InvalidCommandError.new("command is missing")
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
3llo-1.3.1 lib/3llo/command/list.rb
3llo-1.3.1.pre.rc.0 lib/3llo/command/list.rb
3llo-1.2.0 lib/3llo/command/list.rb