-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
58 lines (50 loc) · 1.23 KB
/
main.go
File metadata and controls
58 lines (50 loc) · 1.23 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
package main
import (
"flag"
"fmt"
"os"
application "github.com/feherkaroly/vc/internal/app"
"github.com/feherkaroly/vc/internal/config"
)
var Version = "2.8.4"
func main() {
showVersion := flag.Bool("version", false, "Show version")
leftDir := flag.String("left", ".", "Left panel directory")
rightDir := flag.String("right", ".", "Right panel directory")
flag.Parse()
if *showVersion {
fmt.Printf("vc %s\n", Version)
return
}
// Use saved paths if no explicit arguments given
if *leftDir == "." && *rightDir == "." {
cfg := config.Load()
if cfg.LeftPanel.Path != "" {
if info, err := os.Stat(cfg.LeftPanel.Path); err == nil && info.IsDir() {
*leftDir = cfg.LeftPanel.Path
}
}
if cfg.RightPanel.Path != "" {
if info, err := os.Stat(cfg.RightPanel.Path); err == nil && info.IsDir() {
*rightDir = cfg.RightPanel.Path
}
}
}
// Resolve relative paths
if *leftDir == "." {
if wd, err := os.Getwd(); err == nil {
*leftDir = wd
}
}
if *rightDir == "." {
if wd, err := os.Getwd(); err == nil {
*rightDir = wd
}
}
application.Version = Version
app := application.New(*leftDir, *rightDir)
if err := app.Run(); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
}