github.com/TrueBlocks/trueblocks-core/src/apps/chifra@v0.0.0-20241022031540-b362680128f7/cmd/version.go (about)

     1  // Copyright 2021 The TrueBlocks Authors. All rights reserved.
     2  // Use of this source code is governed by a license that can
     3  // be found in the LICENSE file.
     4  
     5  package cmd
     6  
     7  import (
     8  	"fmt"
     9  
    10  	"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/version"
    11  	"github.com/spf13/cobra"
    12  )
    13  
    14  // Make a copy of this so we don't have to import the version package in every file
    15  const versionText = version.LibraryVersion
    16  
    17  // This allows the user to type chifra version and get the version number. Previously, each
    18  // tool had a --version option (and still do), but this is closer to expected behaviour.
    19  var versionCmd = &cobra.Command{
    20  	Use:   "version",
    21  	Short: "Print the version number of Chifra",
    22  	Long:  `All software has versions. This is Chifra's`,
    23  	Run: func(cmd *cobra.Command, args []string) {
    24  		fmt.Println(versionText)
    25  	},
    26  }
    27  
    28  func init() {
    29  	chifraCmd.AddCommand(versionCmd)
    30  }