Created
April 25, 2018 11:17
-
-
Save adamluzsi/136c78a989daf69a18a61f8367151cd4 to your computer and use it in GitHub Desktop.
golang flag how to create aliases for set flags such as short versions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
var flagAlias = map[string]string{ | |
"long-version": "lv", | |
} | |
func init() { | |
for from, to := range flagAlias { | |
flagSet := flag.Lookup(from) | |
cli.Var(flagSet.Value, to, fmt.Sprintf("alias to %s", flagSet.Name)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment