Sha256: 6e47490b62c090c75febc0cade08970001d4e8264d18236eab1d725bbf694242
Contents?: true
Size: 1.07 KB
Versions: 24
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true require 'avm/tools/core_ext' module Avm module Tools class Runner class Git class DirtyFiles DEFAULT_FORMAT = '%p' FIELDS = { i: :index, w: :worktree, p: :path, a: :absolute_path }.map { |k, v| ["%#{k}", v] }.to_h runner_with :help do desc 'Lists dirty files in Git repository.' arg_opt '-f', '--format', "Format of each line (See \"Format fields\") [default: #{DEFAULT_FORMAT}]." end def help_extra_text "Format fields:\n" + FIELDS.map { |k, v| " #{k} => #{v}" }.join("\n") end def run runner_context.call(:git).dirty_files.each do |file| out("#{format_file(file)}\n") end end private def format parsed.format || DEFAULT_FORMAT end def format_file(file) FIELDS.inject(format) { |a, e| a.gsub(e.first, file.send(e.last)) } end end end end end end
Version data entries
24 entries across 24 versions & 1 rubygems