diff --git a/tools/profileBuilder/cmd/latest.go b/tools/profileBuilder/cmd/latest.go index 3ca398a0b441..ecb523daf41a 100644 --- a/tools/profileBuilder/cmd/latest.go +++ b/tools/profileBuilder/cmd/latest.go @@ -68,17 +68,23 @@ By default, this command ignores API versions that are in preview.`, if viper.GetBool(previewLongName) { packageStrategy.Predicate = model.AcceptAll + outputLog.Println("Using preview versions.") } model.BuildProfile( packageStrategy, - viper.GetString(nameLongName), - viper.GetString(outputLocationLongName), + *nameToUse, + *outputLocationName, outputLog, errLog) }, } +// This is technical debt. It is being tracked by issue: +// https://github.com/Azure/azure-sdk-for-go/issues/1060 +var outputLocationName *string +var nameToUse *string + func init() { rootCmd.AddCommand(latestCmd) @@ -93,15 +99,13 @@ func init() { // latestCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") latestCmd.Flags().BoolP(previewLongName, previewShortName, previewDefault, previewDescription) - viper.BindPFlag(previewLongName, latestCmd.Flags().Lookup(previewLongName)) - latestCmd.Flags().StringP(outputLocationLongName, outputLocationShortName, outputLocationDefault, outputLocationDescription) - viper.BindPFlag(outputLocationLongName, latestCmd.Flags().Lookup(outputLocationLongName)) + outputLocationName = latestCmd.Flags().StringP(outputLocationLongName, outputLocationShortName, outputLocationDefault, outputLocationDescription) - latestCmd.Flags().StringP(nameLongName, nameShortName, nameDefault, nameDescription) - viper.BindPFlag(nameLongName, latestCmd.Flags().Lookup(nameLongName)) - viper.SetDefault(nameLongName, randname.Generate()) + nameToUse = latestCmd.Flags().StringP(nameLongName, nameShortName, nameDefault, nameDescription) latestCmd.Flags().StringP(rootLongName, rootShortName, rootDefault, rootDescription) - viper.BindPFlag(rootLongName, latestCmd.Flags().Lookup(rootLongName)) + + viper.BindPFlags(latestCmd.Flags()) + viper.SetDefault(nameLongName, randname.Generate()) } diff --git a/tools/profileBuilder/cmd/list.go b/tools/profileBuilder/cmd/list.go index 100fdbe915a7..a0d4e6ba90de 100644 --- a/tools/profileBuilder/cmd/list.go +++ b/tools/profileBuilder/cmd/list.go @@ -1,6 +1,6 @@ // +build go1.9 -// Copyright © 2018 2018 Microsoft Corporation +// Copyright © 2018 Microsoft Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -54,8 +54,8 @@ $> ../model/testdata/smallProfile.txt > profileBuilder list --name small_profile model.BuildProfile( &model.ListStrategy{Reader: os.Stdin}, - viper.GetString(nameLongName), - viper.GetString(outputLocationLongName), + *nameToUse, + *outputLocationName, outputLog, errLog) }, @@ -74,10 +74,10 @@ func init() { // is called directly, e.g.: // listCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") - listCmd.Flags().StringP(outputLocationLongName, outputLocationShortName, outputLocationDefault, outputLocationDescription) - viper.BindPFlag(outputLocationLongName, listCmd.Flags().Lookup(outputLocationLongName)) + outputLocationName = listCmd.Flags().StringP(outputLocationLongName, outputLocationShortName, outputLocationDefault, outputLocationDescription) + nameToUse = listCmd.Flags().StringP(nameLongName, nameShortName, nameDefault, nameDescription) + + viper.BindPFlags(listCmd.Flags()) - listCmd.Flags().StringP(nameLongName, nameShortName, nameDefault, nameDescription) - viper.BindPFlag(nameLongName, listCmd.Flags().Lookup(nameLongName)) viper.SetDefault(nameLongName, randname.Generate()) }