surtur
4b6e655ebf
All checks were successful
continuous-integration/drone/push Build is passing
* add 'version' command - "go-xkcdreader version" returns a formatted version of the app * test (among other things) that the version in flake.nix matches the version hardcoded in app's go code (cmd/version.go)
36 lines
662 B
Go
36 lines
662 B
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// appName is the name of the app
|
|
const appName = "go-xkcdreader"
|
|
|
|
// Root is the main go-xkcdreader command
|
|
var Root = &cobra.Command{
|
|
Use: appName,
|
|
Short: "an offline-capable xkcd webcomic reader written in Go",
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
// the app will be started from here
|
|
// a noop atm
|
|
return nil
|
|
},
|
|
}
|
|
|
|
// GetAppName returns the name of the application
|
|
func GetAppName() string {
|
|
return appName
|
|
}
|
|
|
|
// Execute is the entrypoint of cobra's poison
|
|
func Execute() {
|
|
if err := Root.Execute(); err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
os.Exit(1)
|
|
}
|
|
}
|