Sha256: ab587da984029e804607609a5aa4cac33f8251da4e6bbbf55f9c1d1337becb47

Contents?: true

Size: 929 Bytes

Versions: 3

Compression:

Stored size: 929 Bytes

Contents

module Troo
  module CLI
    module Helpers
      def set_default
        return success if resource && resource.set_default!
        not_found
      end

      def success
        say "'#{resource.decorator.name}' set as default #{type.to_s.downcase}."
        true
      end

      def not_found
        say "#{type.to_s.capitalize} cannot be found. Specify a different <id> or use 'troo default #{type.to_s} <id>' to set a default #{type.to_s} first."
        false
      end

      def resource
        @resource = case type
        when :board then @board ||= BoardRetrieval.retrieve(id)
        when :list  then @list  ||= ListRetrieval.retrieve(id)
        when :card  then @card  ||= CardRetrieval.retrieve(id)
        end
      end
    end

    class ThorFixes < Thor
      def self.banner(command, namespace = nil, subcommand = false)
        "#{basename} #{@package_name} #{command.usage}"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
troo-0.0.7 lib/troo/cli/cli_helpers.rb
troo-0.0.6 lib/troo/cli/cli_helpers.rb
troo-0.0.5 lib/troo/cli/cli_helpers.rb