-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
67 lines (59 loc) · 1.91 KB
/
main.go
File metadata and controls
67 lines (59 loc) · 1.91 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 (
_ "embed"
"fmt"
"os"
tea "github.com/charmbracelet/bubbletea"
"github.com/fezcode/atlas.deck/internal/config"
"github.com/fezcode/atlas.deck/internal/ui"
)
var Version = "dev"
//go:embed deck.piml
var defaultDeck []byte
func main() {
if len(os.Args) > 1 {
arg := os.Args[1]
if arg == "-v" || arg == "--version" {
fmt.Printf("atlas.deck v%s\n", Version)
return
}
if arg == "-h" || arg == "--help" || arg == "help" {
showHelp()
return
}
if arg == "-c" || arg == "--create" {
err := os.WriteFile("deck.piml", defaultDeck, 0644)
if err != nil {
fmt.Fprintf(os.Stderr, "Error creating deck.piml: %v\n", err)
os.Exit(1)
}
fmt.Println("Successfully created 'deck.piml' in the current directory.")
return
}
}
deck, err := config.LoadDeck()
if err != nil {
fmt.Fprintf(os.Stderr, "Error loading deck: %v\n", err)
os.Exit(1)
}
p := tea.NewProgram(ui.NewModel(deck), tea.WithAltScreen())
if _, err := p.Run(); err != nil {
fmt.Fprintf(os.Stderr, "Error running program: %v\n", err)
os.Exit(1)
}
}
func showHelp() {
fmt.Printf("atlas.deck v%s - Interactive TUI command deck for project workflows.\n\n", Version)
fmt.Println("Usage:")
fmt.Println(" atlas.deck Start the interactive TUI")
fmt.Println(" atlas.deck -c, --create Create a 'deck.piml' file in the current directory")
fmt.Println(" atlas.deck -h, --help Show this help information")
fmt.Println(" atlas.deck -v, --version Show version information")
fmt.Println("\nBlueprint:")
fmt.Println(" The application looks for a 'deck.piml' file in the current directory.")
fmt.Println(" If not found, it falls back to the global configuration in ~/.atlas/deck.piml.")
fmt.Println("\nTUI Controls:")
fmt.Println(" [Key] Execute the command mapped to that key")
fmt.Println(" ctrl+l Clear the log view")
fmt.Println(" ctrl+c Quit the application")
}