Adds version information to cordless.
The version can be request via startup parameter `--version` or the `version`
command within cordless.
MODIFY
app/app.go
app/app.go
@@ -89,6 +89,7 @@ func Run() {
log.Fatalf("Error constructing window (%s).\n", createError.Error())
}
+ window.RegisterCommand(commandimpls.NewVersionCommand())
statusGetCmd := commandimpls.NewStatusGetCommand(discord)
statusSetCmd := commandimpls.NewStatusSetCommand(discord)
window.RegisterCommand(statusSetCmd)

ADD
commands/commandimpls/version.go
+package commandimpls
+
+import (
+ "fmt"
+ "github.com/Bios-Marcel/cordless/version"
+ "io"
+)
+
+const versionDocumentation = `[::b]NAME
+ version - Displays the version of cordless you are running
+
+[::b]SYNOPSIS
+ [::b]version
+
+[::b]DESCRIPTION
+ This command displays the version of cordless that you are running.
+ The version is the in the format Year-Month-Day and is the date on which
+ the version you are using was built. If you have manually built cordless,
+ your installation might contain commits which aren't part of the stated
+ version.`
+
+
+type VersionCmd struct{}
+
+func NewVersionCommand() *VersionCmd {
+ return &VersionCmd{}
+}
+
+func (cmd VersionCmd) Execute(writer io.Writer, parameters []string) {
+ fmt.Fprintf(writer, "You are running cordless version %s\n", version.Version)
+}
+
+func (cmd VersionCmd) PrintHelp(writer io.Writer) {
+ fmt.Println(writer, versionDocumentation)
+}
+
+func (cmd VersionCmd) Name() string {
+ return "version"
+}
+
+func (cmd VersionCmd) Aliases() []string {
+ return nil
+}
+
+

MODIFY
main.go
main.go
package main
-import "github.com/Bios-Marcel/cordless/app"
+import (
+ "flag"
+ "fmt"
+ "github.com/Bios-Marcel/cordless/app"
+ "github.com/Bios-Marcel/cordless/version"
+)
func main() {
+ showVersion := flag.Bool("version", false, "Show the version instead of starting cordless")
+ flag.Parse()
+
+ if showVersion != nil && *showVersion {
+ fmt.Printf("You are running cordless version %s\nKeep in mind that this version might not be correct for manually built versions, as those can contain additional commits.\n", version.Version)
+ } else {
app.Run()
}
+}

ADD
version/version.go
+package version
+
+var Version = "2019-08-29"
\ No newline at end of file

Adds version information to cordless.

The version can be request via startup parameter `--version` or the `version`
command within cordless.