summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go26
1 files changed, 16 insertions, 10 deletions
diff --git a/main.go b/main.go
index db483e5..48121a7 100644
--- a/main.go
+++ b/main.go
@@ -3,23 +3,23 @@ package main
import (
"log/slog"
"os"
+ "time"
+ "github.com/ChausseBenjamin/termpicker/internal/logging"
"github.com/ChausseBenjamin/termpicker/internal/switcher"
"github.com/ChausseBenjamin/termpicker/internal/util"
tea "github.com/charmbracelet/bubbletea"
"github.com/urfave/cli/v2"
)
-func AppAction(ctx *cli.Context) error {
- logFile, err := os.Create(ctx.String(flagLogfile))
- if err != nil {
- slog.Error("Failed to create log file", util.ErrKey, err.Error())
- os.Exit(1)
- }
- defer logFile.Close()
+var ( // Set by the build system
+ version = "DEVELOPMENT-SNAPSHOT"
+ date = ""
+)
- handler := slog.NewJSONHandler(logFile, nil)
- slog.SetDefault(slog.New(handler))
+func AppAction(ctx *cli.Context) error {
+ logfile := logging.Setup(ctx.String("logfile"))
+ defer logfile.Close()
slog.Info("Starting Termpicker")
@@ -37,11 +37,17 @@ func AppAction(ctx *cli.Context) error {
}
func main() {
+ compileDate, _ := time.Parse(time.RFC3339, date)
app := &cli.App{
Name: "Termpicker",
Usage: "A terminal-based color picker",
Action: AppAction,
- Flags: AppFlags,
+ Authors: []*cli.Author{
+ {Name: "Benjamin Chausse", Email: "benjamin@chausse.xyz"},
+ },
+ Version: version,
+ Flags: AppFlags,
+ Compiled: compileDate,
}
if err := app.Run(os.Args); err != nil {
slog.Error("Program crashed", util.ErrKey, err.Error())