-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
67 lines (58 loc) · 1.4 KB
/
main.go
File metadata and controls
67 lines (58 loc) · 1.4 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"flag"
"fmt"
"os"
"dev/internal/app"
"dev/internal/filesystem"
"dev/internal/terminal"
"dev/internal/tui"
)
var version string
func main() {
var printVersion bool
var printPath bool
var noUpdateTitle bool
flag.BoolVar(&printVersion, "v", false, "print version")
flag.BoolVar(&printVersion, "version", false, "print version")
flag.BoolVar(&printPath, "p", false, "print selected project path to stdout")
flag.BoolVar(&printPath, "print-path", false, "print selected project path to stdout")
flag.BoolVar(&noUpdateTitle, "n", false, "do not update terminal tab title")
flag.BoolVar(&noUpdateTitle, "no-update-title", false, "do not update terminal tab title")
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: dev [options] [path...]\n\n")
fmt.Fprintf(os.Stderr, "Options:\n")
flag.PrintDefaults()
}
flag.Parse()
if printVersion {
if version == "" {
version = "snapshot"
}
fmt.Printf("%s\n", version)
os.Exit(0)
}
cfg := app.Config{
Args: flag.Args(),
Flags: app.Flags{
PrintPath: printPath,
NoUpdateTitle: noUpdateTitle,
},
Term: terminal.Detect(),
Fs: &filesystem.RealFileSystem{},
Icons: tui.Icons{
Dir: "",
Term: "",
},
}
res, err := app.Run(cfg).Get()
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
_, err = fmt.Fprintln(os.Stdout, res)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}