gci is configured with the sections standard, default and localmodule, and goimports with the module path as its local prefix, so both formatters agree.
38 lines
881 B
Go
38 lines
881 B
Go
package version
|
|
|
|
import (
|
|
"fmt"
|
|
"log/slog"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"git.avsdev.uk/Go/job-search/internal/version"
|
|
)
|
|
|
|
// NewCommand returns the "version" command.
|
|
func NewCommand() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "version",
|
|
Short: "Print version information",
|
|
SilenceUsage: true,
|
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
|
slog.Debug("version.PersistentPreRun")
|
|
},
|
|
PersistentPostRun: func(cmd *cobra.Command, args []string) {
|
|
slog.Debug("version.PersistentPostRun")
|
|
},
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
slog.Debug("version.Run")
|
|
|
|
fmt.Printf("JobSearch - %s\n", version.Version)
|
|
if version.BuildTime != "unknown" {
|
|
fmt.Printf("Built: %s\n", version.BuildTime)
|
|
}
|
|
if version.GitCommit != "unknown" {
|
|
fmt.Printf("Commit: %s\n", version.GitCommit)
|
|
}
|
|
},
|
|
}
|
|
return cmd
|
|
}
|