github.com/vmware/govmomi@v0.51.0/cli/register.go (about) 1 // © Broadcom. All Rights Reserved. 2 // The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 3 // SPDX-License-Identifier: Apache-2.0 4 5 package cli 6 7 import "os" 8 9 var commands = map[string]Command{} 10 11 var aliases = map[string]string{} 12 13 // hideUnreleased allows commands to be compiled into the govc binary without being registered by default. 14 // Unreleased commands are omitted from 'govc -h' help text and the generated govc/USAGE.md 15 // Setting the env var GOVC_SHOW_UNRELEASED=true enables any commands registered as unreleased. 16 var hideUnreleased = os.Getenv("GOVC_SHOW_UNRELEASED") != "true" 17 18 func ShowUnreleased() bool { 19 return !hideUnreleased 20 } 21 22 func Register(name string, c Command, unreleased ...bool) { 23 if len(unreleased) != 0 && unreleased[0] && hideUnreleased { 24 return 25 } 26 commands[name] = c 27 } 28 29 func Alias(name string, alias string) { 30 aliases[alias] = name 31 } 32 33 func Commands() map[string]Command { 34 return commands 35 }