Skip to content

Commit

Permalink
fine-grant the output behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
lotusirous committed Oct 29, 2022
1 parent 45710f9 commit 7caa362
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions fp.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"io"
"log"
"os"
"strings"

"github.com/atotto/clipboard"
)
Expand Down Expand Up @@ -72,9 +73,8 @@ func main() {
}

rr := NewRowRender()
rr.AddRow("", abs)

if *flagVerbose && !fi.IsDir() {
if *flagVerbose {
if fi.IsDir() {
rr.AddRow("DIR", abs)
} else {
Expand All @@ -92,12 +92,16 @@ func main() {
}
rr.AddRowMap(values)
rr.Write(os.Stdout)
return
}
rr.AddRow("", abs)

if *flagClip {
buf := new(bytes.Buffer)
rr.Write(buf)
clipboard.WriteAll(buf.String())
line := buf.String()
clipboard.WriteAll(strings.TrimSuffix(line, "\n"))
return
}
rr.Write(os.Stdout)
}

0 comments on commit 7caa362

Please sign in to comment.