github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/go/not-internal/base/flag.go (about) 1 // Copyright 2017 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package base 6 7 import ( 8 "flag" 9 10 "github.com/gagliardetto/golang-go/cmd/go/not-internal/cfg" 11 "github.com/gagliardetto/golang-go/cmd/go/not-internal/str" 12 ) 13 14 // A StringsFlag is a command-line flag that interprets its argument 15 // as a space-separated list of possibly-quoted strings. 16 type StringsFlag []string 17 18 func (v *StringsFlag) Set(s string) error { 19 var err error 20 *v, err = str.SplitQuotedFields(s) 21 if *v == nil { 22 *v = []string{} 23 } 24 return err 25 } 26 27 func (v *StringsFlag) String() string { 28 return "<StringsFlag>" 29 } 30 31 // AddBuildFlagsNX adds the -n and -x build flags to the flag set. 32 func AddBuildFlagsNX(flags *flag.FlagSet) { 33 flags.BoolVar(&cfg.BuildN, "n", false, "") 34 flags.BoolVar(&cfg.BuildX, "x", false, "") 35 } 36 37 // AddLoadFlags adds the -mod build flag to the flag set. 38 func AddLoadFlags(flags *flag.FlagSet) { 39 flags.StringVar(&cfg.BuildMod, "mod", "", "") 40 }