Sha256: 22aac6586e6f2f7706a1cebd5e04f932eb08b4ee570c74c7cc170ba3c1a0320f
Contents?: true
Size: 1.15 KB
Versions: 3
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true require_relative '../interactive_ops' module Codeowners module Cli module Wizards # Suggests to fix unrecognized lines in the codeowners file. # Only returns decision without applying any modifications. class UnrecognizedLineWizard include InteractiveOps def suggest_fixing(line) case prompt(line) when 'i' then :ignore when 'y' then [:replace, keep_asking_until_valid_line] when 'd' then :delete end end private def prompt(line) ask(<<~QUESTION, limited_to: %w[y i d]) #{line.to_s.inspect} is in unrecognized format. Would you like to edit? (y) yes (i) ignore (d) delete the line QUESTION end def keep_asking_until_valid_line line = nil loop do new_line_string = ask('New line: ') line = Codeowners::Checker::Group::Line.build(new_line_string) break unless line.is_a?(Codeowners::Checker::Group::UnrecognizedLine) end line end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems