#!/usr/bin/env fish

#set fish_trace 1

set file $argv[-1]
#golangci-lint $argv[1..-2] | sed -n "/$file/,+2p"

set capture false

golangci-lint $argv[1..-2] | while read --local --line line
    if string match --quiet --regex '^.+:[0-9]+:' $line
        if test $file = (string match --regex '[^:]+' $line)
            set capture true
        else
            set capture false
        end
    end

    if test $capture = true
        echo $line
    end
end
