cli + tui to publish to leaflet (wip) & manage tasks, notes & watch/read lists 馃崈
charm leaflet readability golang
29
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 7da458848ced66d8eab8b2e86c031c8dc4e0e6fc 73 lines 1.6 kB view raw
1package main 2 3import ( 4 "context" 5 "fmt" 6 "os" 7 8 "github.com/charmbracelet/fang" 9 "github.com/spf13/cobra" 10 "github.com/stormlightlabs/noteleaf/internal/store" 11 "github.com/stormlightlabs/noteleaf/internal/ui" 12 "github.com/stormlightlabs/noteleaf/internal/utils" 13) 14 15// App represents the main CLI application 16type App struct { 17 db *store.Database 18 config *store.Config 19} 20 21// NewApp creates a new CLI application instance 22func NewApp() (*App, error) { 23 db, err := store.NewDatabase() 24 if err != nil { 25 return nil, fmt.Errorf("failed to initialize database: %w", err) 26 } 27 28 if config, err := store.LoadConfig(); err != nil { 29 return nil, fmt.Errorf("failed to load configuration: %w", err) 30 } else { 31 return &App{db: db, config: config}, nil 32 } 33} 34 35// Close cleans up application resources 36func (app *App) Close() error { 37 if app.db != nil { 38 return app.db.Close() 39 } 40 return nil 41} 42 43func main() { 44 logger := utils.NewLogger("info", "text") 45 utils.Logger = logger 46 47 app, err := NewApp() 48 if err != nil { 49 logger.Fatal("Failed to initialize application", "error", err) 50 } 51 defer app.Close() 52 53 root := rootCmd() 54 commands := []func() *cobra.Command{ 55 setupCmd, resetCmd, statusCmd, todoCmd, 56 movieCmd, noteCmd, tvCmd, bookCmd, confCmd, 57 } 58 59 for _, cmdFunc := range commands { 60 cmd := cmdFunc() 61 root.AddCommand(cmd) 62 } 63 64 options := []fang.Option{ 65 fang.WithVersion("0.1.0"), 66 fang.WithoutCompletions(), 67 fang.WithColorSchemeFunc(ui.NoteleafColorScheme), 68 } 69 70 if err := fang.Execute(context.Background(), root, options...); err != nil { 71 os.Exit(1) 72 } 73}