Skip to content

Commit

Permalink
Working around #1060
Browse files Browse the repository at this point in the history
  • Loading branch information
marstr committed Feb 8, 2018
1 parent 3debc48 commit e225c66
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
22 changes: 13 additions & 9 deletions tools/profileBuilder/cmd/latest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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())
}
14 changes: 7 additions & 7 deletions tools/profileBuilder/cmd/list.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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)
},
Expand All @@ -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())
}

0 comments on commit e225c66

Please sign in to comment.