Sha256: ca06c86eec6fd27924f427d54777fcf9a1bebbca489c40296e606216923aa764
Contents?: true
Size: 1.07 KB
Versions: 189
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 }.transform_keys { |k| "%#{k}" } 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
189 entries across 189 versions & 2 rubygems