Sha256: ad440b5f75e8b4a0f10b25f703442dc81d0b34a89e5a417042ab9655e222ab3a

Contents?: true

Size: 655 Bytes

Versions: 7

Compression:

Stored size: 655 Bytes

Contents

module Toolshed
  module Commands
    class CheckoutBranch
      def execute(args, options = {})
        branch_name = read_user_input("Ticket ID or Branch Name:", options)
        branch_name = Toolshed::Git::Base.checkout(branch_name)
        puts "Switched to '#{branch_name}'"
      end

      def read_user_input(message, options)
        return options[:branch_name] if (options.has_key?(:branch_name))

        puts message
        value = $stdin.gets.chomp

        until (!value.empty?)
          puts "Branch name cannot be empty"
          puts message
          value = $stdin.gets.chomp
        end

        value
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
toolshed-1.0.2 lib/toolshed/commands/checkout_branch.rb
toolshed-1.0.1 lib/toolshed/commands/checkout_branch.rb
toolshed-1.0.0 lib/toolshed/commands/checkout_branch.rb
toolshed-0.0.9 lib/toolshed/commands/checkout_branch.rb
toolshed-0.0.8 lib/toolshed/commands/checkout_branch.rb
toolshed-0.0.7 lib/toolshed/commands/checkout_branch.rb
toolshed-0.0.6 lib/toolshed/commands/checkout_branch.rb