|
| 1 | +/* |
| 2 | +Copyright © LiquidWeb |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | +package cmd |
| 17 | + |
| 18 | +import ( |
| 19 | + "fmt" |
| 20 | + |
| 21 | + "github.com/spf13/cobra" |
| 22 | +) |
| 23 | + |
| 24 | +// default build-time variables; these are overridden via ldflags |
| 25 | +var ( |
| 26 | + Version = "unknown-version" |
| 27 | + GitCommit = "unknown-commit" |
| 28 | + BuildTime = "unknown-buildtime" |
| 29 | +) |
| 30 | + |
| 31 | +var versionCmd = &cobra.Command{ |
| 32 | + Use: "version", |
| 33 | + Short: "show build information", |
| 34 | + Long: `Show build information. |
| 35 | +
|
| 36 | +This information should be provided with any bug report.`, |
| 37 | + Run: func(cmd *cobra.Command, args []string) { |
| 38 | + fmt.Printf("LiquidWeb CLI Build Details\n\n") |
| 39 | + fmt.Printf(" Build Time: %s\n", BuildTime) |
| 40 | + fmt.Printf(" Version: %s\n", Version) |
| 41 | + fmt.Printf(" Git commit: %s\n\n", GitCommit) |
| 42 | + }, |
| 43 | +} |
| 44 | + |
| 45 | +func init() { |
| 46 | + rootCmd.AddCommand(versionCmd) |
| 47 | +} |
0 commit comments