github.com/Microsoft/fabrikate@v0.0.0-20190420002442-bff75be28d02/cmd/version.go (about)

     1  // Copyright © 2018 NAME HERE <EMAIL ADDRESS>
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package cmd
    16  
    17  import (
    18  	log "github.com/sirupsen/logrus"
    19  	"github.com/spf13/cobra"
    20  )
    21  
    22  // versionCmd represents the version command
    23  var versionCmd = &cobra.Command{
    24  	Use:   "version",
    25  	Short: "A brief description of your command",
    26  	Long: `A longer description that spans multiple lines and likely contains examples
    27  and usage of using your command. For example:
    28  
    29  Cobra is a CLI library for Go that empowers applications.
    30  This application is a tool to generate the needed files
    31  to quickly create a Cobra application.`,
    32  	Run: func(cmd *cobra.Command, args []string) {
    33  		PrintVersion()
    34  	},
    35  }
    36  
    37  func PrintVersion() {
    38  	log.Println("fab version 0.5.1")
    39  }
    40  
    41  func init() {
    42  	rootCmd.AddCommand(versionCmd)
    43  
    44  	// Here you will define your flags and configuration settings.
    45  
    46  	// Cobra supports Persistent Flags which will work for this command
    47  	// and all subcommands, e.g.:
    48  	// versionCmd.PersistentFlags().String("foo", "", "A help for foo")
    49  
    50  	// Cobra supports local flags which will only run when this command
    51  	// is called directly, e.g.:
    52  	// versionCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
    53  }