github.com/actions-on-google/gactions@v3.2.0+incompatible/cmd/gactions/cli/version/version.go (about) 1 // Copyright 2020 Google LLC 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 // https://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 version implements "gactions version" command. 16 package version 17 18 import ( 19 "github.com/actions-on-google/gactions/log" 20 "github.com/actions-on-google/gactions/versions" 21 "github.com/spf13/cobra" 22 ) 23 24 // AddCommand adds the push sub-command to the passed in root command. 25 func AddCommand(root *cobra.Command) { 26 version := &cobra.Command{ 27 Use: "version", 28 Short: "Prints current version of the CLI.", 29 Long: "Prints current version of the CLI.", 30 RunE: func(cmd *cobra.Command, args []string) error { 31 log.Outf("%s\n", versions.CliVersion) 32 return nil 33 }, 34 Args: cobra.NoArgs, 35 } 36 root.AddCommand(version) 37 }