ignore
1package cmd2
3import (4"fmt"5"github.com/charmbracelet/lipgloss"6"github.com/neptunsk1y/ignore/version"7"github.com/spf13/cobra"8"html/template"9"runtime"10)
11
12func init() {13rootCmd.AddCommand(versionCmd)14}
15
16var versionCmd = &cobra.Command{17Use: "version",18Short: "Print the version number of the ignore",19Run: func(cmd *cobra.Command, args []string) {20_, err := version.Latest()21if err != nil {22fmt.Println("Error version check")23}24
25versionInfo := struct {26Version string27OS string28Arch string29App string30Compiler string31}{32Version: version.Version,33App: "ignore",34OS: runtime.GOOS,35Arch: runtime.GOARCH,36Compiler: runtime.Compiler,37}38
39t, err := template.New("version").Funcs(map[string]any{40"faint": lipgloss.NewStyle().Faint(true).Render,41"bold": lipgloss.NewStyle().Bold(true).Render,42"magenta": lipgloss.NewStyle().Foreground(lipgloss.Color("#5a6368")).Render,43}).Parse(`{{ magenta "▇▇▇" }} {{ magenta .App }}44
45{{ faint "Version" }} {{ bold .Version }}
46{{ faint "Platform" }} {{ bold .OS }}/{{ bold .Arch }}
47{{ faint "Compiler" }} {{ bold .Compiler }}
48`)49handleErr(err)50handleErr(t.Execute(cmd.OutOrStdout(), versionInfo))51},52}
53