-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathversion.go
64 lines (54 loc) · 1.63 KB
/
version.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright (c) 2016, Ben Morgan. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
package main
import (
"text/template"
"github.com/cassava/repoctl/internal/term"
"github.com/spf13/cobra"
)
func init() {
MainCmd.AddCommand(versionCmd)
}
var versionCmd = &cobra.Command{
Use: "version",
Short: "Show version information and current configuration",
Long: "Show version information of repoctl, as well as the current configuration.",
ValidArgsFunction: completeNoFiles,
Args: cobra.ExactArgs(0),
DisableFlagsInUseLine: true,
Run: func(cmd *cobra.Command, args []string) {
exceptQuiet()
var progInfo = struct {
Name string
Author string
Email string
Version string
Date string
Homepage string
Copyright string
License string
}{
Name: "repoctl",
Author: "Ben Morgan",
Email: "[email protected]",
Version: "0.22.2",
Date: "23 March, 2024",
Copyright: "2016-2024",
Homepage: "https://github.com/cassava/repoctl",
License: "MIT",
}
versionTmpl.Execute(term.StdOut, progInfo)
// Print the current configuration.
term.Println()
Conf.WriteProperties(term.StdOut)
},
}
var versionTmpl = template.Must(template.New("version").Parse(
`{{.Name}} version {{.Version}} ({{.Date}})
Copyright {{.Copyright}}, {{.Author}} <{{.Email}}>
You may find {{.Name}} on the Internet at
{{.Homepage}}
Please report any bugs you may encounter.
The source code of {{.Name}} is licensed under the {{.License}} license.
`))