-
-
Notifications
You must be signed in to change notification settings - Fork 275
/
main.go
57 lines (49 loc) · 1.04 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
_ "embed"
"os"
"time"
tea "github.com/charmbracelet/bubbletea"
"github.com/maaslalani/slides/internal/cmd"
"github.com/maaslalani/slides/internal/model"
"github.com/maaslalani/slides/internal/navigation"
"github.com/muesli/coral"
)
var (
rootCmd = &coral.Command{
Use: "slides <file.md>",
Short: "Terminal based presentation tool",
Args: coral.ArbitraryArgs,
RunE: func(cmd *coral.Command, args []string) error {
var err error
var fileName string
if len(args) > 0 {
fileName = args[0]
}
presentation := model.Model{
Page: 0,
Date: time.Now().Format("2006-01-02"),
FileName: fileName,
Search: navigation.NewSearch(),
}
err = presentation.Load()
if err != nil {
return err
}
p := tea.NewProgram(presentation, tea.WithAltScreen())
_, err = p.Run()
return err
},
}
)
func init() {
rootCmd.AddCommand(
cmd.ServeCmd,
)
rootCmd.CompletionOptions.DisableDefaultCmd = true
}
func main() {
if err := rootCmd.Execute(); err != nil {
os.Exit(1)
}
}