-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
45 lines (39 loc) · 707 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"fmt"
"github.com/drn/nerd-ls/format"
"github.com/drn/nerd-ls/options"
"github.com/fatih/color"
"github.com/jessevdk/go-flags"
"os"
)
var opts options.Options
func main() {
args, err := flags.ParseArgs(&opts, os.Args)
if flags.WroteHelp(err) {
return
}
if err != nil {
fmt.Println()
flags.ParseArgs(&opts, []string{"--help"})
os.Exit(1)
}
var dirs []string
if len(args) == 1 {
dirs = []string{"."}
} else {
dirs = args[1:]
}
for i, dir := range dirs {
if len(dirs) > 1 {
if i > 0 {
fmt.Println()
}
fmt.Printf(
"%s:\n",
color.New(color.FgMagenta, color.Bold).Sprint(dir),
)
}
format.Display(dir, options.Parse(opts))
}
}