github.com/scaleway/scaleway-cli@v1.11.1/pkg/cli/cmd_version.go (about) 1 // Copyright (C) 2015 Scaleway. All rights reserved. 2 // Use of this source code is governed by a MIT-style 3 // license that can be found in the LICENSE.md file. 4 5 package cli 6 7 import "github.com/scaleway/scaleway-cli/pkg/commands" 8 9 var cmdVersion = &Command{ 10 Exec: runVersion, 11 UsageLine: "version [OPTIONS]", 12 Description: "Show the version information", 13 Help: "Show the version information.", 14 } 15 16 func init() { 17 cmdVersion.Flag.BoolVar(&versionHelp, []string{"h", "-help"}, false, "Print usage") 18 } 19 20 // Flags 21 var versionHelp bool // -h, --help flag 22 23 func runVersion(cmd *Command, rawArgs []string) error { 24 if versionHelp { 25 return cmd.PrintUsage() 26 } 27 if len(rawArgs) != 0 { 28 return cmd.PrintShortUsage() 29 } 30 31 args := commands.VersionArgs{} 32 ctx := cmd.GetContext(rawArgs) 33 return commands.Version(ctx, args) 34 }