hack: parse out the info flags for report subcommands separately

pflag doesn't ignore unspecified arguments, so they must be parsed out separately first.
This commit is contained in:
Jose Diaz-Gonzalez
2020-12-21 01:36:59 -05:00
parent 8240790381
commit 1439e8b30b
13 changed files with 56 additions and 58 deletions

View File

@@ -44,10 +44,12 @@ func main() {
err = buildpacks.CommandRemove(appName, buildpack, *index)
case "report":
args := flag.NewFlagSet("buildpacks:report", flag.ExitOnError)
args.Parse(os.Args[2:])
appName := args.Arg(0)
infoFlag := args.Arg(1)
err = buildpacks.CommandReport(appName, infoFlag)
osArgs, infoFlag, err := common.ParseReportArgs("buildpacks", os.Args[2:])
if err == nil {
args.Parse(osArgs)
appName := args.Arg(0)
err = buildpacks.CommandReport(appName, infoFlag)
}
case "set":
args := flag.NewFlagSet("buildpacks:set", flag.ExitOnError)
index := args.Int("index", 0, "--index: the 1-based index of the URL in the list of URLs")

View File

@@ -3,7 +3,6 @@ package buildpacks
import (
"errors"
"fmt"
"strings"
"github.com/dokku/dokku/plugins/common"
)
@@ -106,11 +105,6 @@ func CommandRemove(appName string, buildpack string, index int) (err error) {
// CommandReport displays a buildpacks report for one or more apps
func CommandReport(appName string, infoFlag string) error {
if strings.HasPrefix(appName, "--") {
infoFlag = appName
appName = ""
}
if len(appName) == 0 {
apps, err := common.DokkuApps()
if err != nil {