Sha256: a07c5be8845511862d7b020e78dbf2523ab4d0485b1c532c3158c20333a98665

Contents?: true

Size: 1.74 KB

Versions: 5

Compression:

Stored size: 1.74 KB

Contents

module Troo
  module CLI
    class Add < ThorFixes
      package_name 'add'

      # @param  [String]
      # @return [String]
      desc 'board (<name>)',
           'Add a new board with <name>; prompts if <name> not ' \
           'provided.'
      def board(name = nil)
        value = name.nil? ? prompt_for_name : name
        say Commands::Add.dispatch(value, nil, type: :board)
      end

      # @param  [String]
      # @param  [String]
      # @return [String]
      desc 'card <list_id> (<name>)',
           'Add a new card to the list with <list_id> with <name>; ' \
           'prompts if <name> not provided.'
      def card(id, name = nil)
        value = name.nil? ? prompt_for_name : name
        say Commands::Add.dispatch(value, id, type: :card)
      end

      # @param  [String]
      # @param  [String]
      # @return [String]
      desc 'comment <card_id> (<comment>)',
           'Add a new comment to the card with <card_id> with ' \
           '<comment>; prompts if <comment> not provided.'
      def comment(id, comment = nil)
        value = comment.nil? ? prompt_for_comment : comment
        say Commands::Add.dispatch(value, id, type: :comment)
      end

      # @param  [String]
      # @param  [String]
      # @return [String]
      desc 'list <board_id> (<name>)',
           'Add a new list to the board with <board_id> with ' \
           '<name>; prompts if <name> not provided.'
      def list(id, name = nil)
        value = name.nil? ? prompt_for_name : name
        say Commands::Add.dispatch(value, id, type: :list)
      end

      private

      def prompt_for_name
        @answer = ask('Please enter a name:')
      end

      def prompt_for_comment
        @answer = ask('Please enter a comment:')
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
troo-0.0.15 lib/troo/cli/add.rb
troo-0.0.14 lib/troo/cli/add.rb
troo-0.0.13 lib/troo/cli/add.rb
troo-0.0.12 lib/troo/cli/add.rb
troo-0.0.11 lib/troo/cli/add.rb