Sha256: 816942ddf1e93761da142898d727c2ada67ab895c145a4a1299f379d934d3d8c

Contents?: true

Size: 875 Bytes

Versions: 104

Compression:

Stored size: 875 Bytes

Contents

# frozen_string_literal: true

module DeclareSchema
  module Support
    module ThorShell
      PREFIX = '  => '

      private

      def ask(statement, default = '', color = :magenta)
        result = super(statement, color)
        result = default if result.blank?
        say PREFIX + result.inspect
        result
      end

      def yes_no?(statement, _color=:magenta)
        result = choose(statement + ' [y|n]', /^(y|n)$/i)
        result == 'y'
      end

      def choose(prompt, format, default=nil)
        choice = ask prompt, default
        if choice =~ format
          choice
        elsif choice.blank? && !default.blank?
          default
        else
          say 'Unknown choice! ', :red
          choose(prompt, format, default)
        end
      end

      def say_title(title)
        say "\n #{title} \n", "\e[37;44m"
      end
    end
  end
end

Version data entries

104 entries across 104 versions & 1 rubygems

Version Path
declare_schema-1.4.0.colin.7 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.4.0.colin.6 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.4.0.colin.5 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.4.0.colin.4 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.4.0.colin.3 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.4.0.colin.2 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.4.0.colin.1 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.3.2 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.3.2.rp.1 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.3.1 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.3.1.colin.1 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.3.0 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.3.0.colin.1 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.2.3 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.2.3.pre.ga.11 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.2.3.pre.ga.10 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.2.3.pre.ga.9 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.2.3.pre.ga.8 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.2.3.pre.ga.7 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.2.3.pre.ga.6 lib/generators/declare_schema/support/thor_shell.rb