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.2.3.pre.ga.5 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.2.3.pre.ga.4 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.2.3.pre.ga.2 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.2.3.pre.ga.1 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.2.3.pre.ga.0 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.2.2 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.2.2.pre.0 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.2.1 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.2.0 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.2.0.pre.1 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.1.0 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.0.2 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.0.1 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-1.0.0 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-0.14.3 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-0.14.2 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-0.14.1 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-0.14.0 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-0.13.2 lib/generators/declare_schema/support/thor_shell.rb
declare_schema-0.13.1 lib/generators/declare_schema/support/thor_shell.rb