-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
45 lines (34 loc) · 891 Bytes
/
main.go
File metadata and controls
45 lines (34 loc) · 891 Bytes
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 (
"log"
"os"
"github.com/knipferrc/fm/app"
"github.com/knipferrc/fm/components"
"github.com/knipferrc/fm/config"
"github.com/knipferrc/fm/filesystem"
tea "github.com/charmbracelet/bubbletea"
)
func main() {
config.SetDefaults()
config.LoadConfig()
cfg := config.GetConfig()
m := app.NewModel()
if cfg.Settings.StartDir == "~" {
home, err := os.UserHomeDir()
if err != nil {
log.Fatal(err)
}
m.Files = filesystem.GetDirectoryListing(home)
} else {
m.Files = filesystem.GetDirectoryListing(cfg.Settings.StartDir)
}
m.PrimaryViewport.SetContent(components.DirTree(m.Files, m.Cursor, m.ScreenWidth))
m.SecondaryViewport.SetContent(components.Instructions())
p := tea.NewProgram(m)
p.EnableMouseCellMotion()
defer p.DisableMouseCellMotion()
if err := p.Start(); err != nil {
log.Fatal("Failed to start fm", err)
os.Exit(1)
}
}