Sha256: 2ad3ac1ce1b13c15cfee305598cca03016389d59f4478445fad16eef5e29d5b0
Contents?: true
Size: 1.32 KB
Versions: 3
Compression:
Stored size: 1.32 KB
Contents
# frozen_string_literal: true require_relative 'make_menu/console/prompter' require_relative 'make_menu/console/color_string' require_relative 'make_menu/menu' require 'tty-screen' module MakeMenu String.include MakeMenu::Console::ColorString trap('SIGINT') { throw StandardError } def self.run(makefile = './Makefile', &block) MakeMenu::Menu.new(makefile).run(&block) end def self.prompt(text = nil, obscure: false, value_from_file: nil) if (preamble = ARGV[0]) if text.nil? if preamble.include?("\n") parts = preamble.split("\n") preamble = parts[0..-2].join("\n") text = parts[-1] puts preamble else text = preamble end end end if value_from_file begin input = Console::Prompter.prompt_and_save text, file: value_from_file, obscure: obscure puts (obscure ? ('*' * input.decolor.size) : input).green.underline rescue Console::Prompter::PressedEscape puts '(not updated)'.red end else begin input = Console::Prompter.prompt text, obscure: obscure puts (obscure ? ('*' * input.decolor.size) : input).green.underline $stderr.puts input rescue Console::Prompter::PressedEscape puts '(not updated)'.red end end input end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
make_menu-2.1.2 | lib/make_menu.rb |
make_menu-2.1.1 | lib/make_menu.rb |
make_menu-2.1.0 | lib/make_menu.rb |