aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/base/flag.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2017-01-18 00:06:08 -0500
committerRuss Cox <rsc@golang.org>2017-02-03 20:31:33 +0000
commit3c667ef421becd1acdbd8ac57503a1cbed47fc5c (patch)
treee5f20397928ede815a1e8ddce709eaa7e8569b36 /src/cmd/go/internal/base/flag.go
parenteb93b20c2ebb9cba89657437615957d5f45b5f6c (diff)
downloadgo-3c667ef421becd1acdbd8ac57503a1cbed47fc5c.tar.gz
go-3c667ef421becd1acdbd8ac57503a1cbed47fc5c.zip
cmd/go: split out cmd/go/internal/work
This is one CL in a long sequence of changes to break up the go command from one package into a plausible group of packages. This sequence is concerned only with moving code, not changing or cleaning up code. There will still be more cleanup after this sequence. The entire sequence will be submitted together: it is not a goal for the tree to build at every step. For #18653. Change-Id: Icdd181098f9f0e81f68bf201e6867cdd8f820300 Reviewed-on: https://go-review.googlesource.com/36197 Reviewed-by: David Crawshaw <crawshaw@golang.org>
Diffstat (limited to 'src/cmd/go/internal/base/flag.go')
-rw-r--r--src/cmd/go/internal/base/flag.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/cmd/go/internal/base/flag.go b/src/cmd/go/internal/base/flag.go
new file mode 100644
index 0000000000..84ea02ad2b
--- /dev/null
+++ b/src/cmd/go/internal/base/flag.go
@@ -0,0 +1,33 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package base
+
+import (
+ "cmd/go/internal/str"
+ "flag"
+)
+
+// A StringsFlag is a command-line flag that interprets its argument
+// as a space-separated list of possibly-quoted strings.
+type StringsFlag []string
+
+func (v *StringsFlag) Set(s string) error {
+ var err error
+ *v, err = str.SplitQuotedFields(s)
+ if *v == nil {
+ *v = []string{}
+ }
+ return err
+}
+
+func (v *StringsFlag) String() string {
+ return "<StringsFlag>"
+}
+
+// AddBuildFlagsNX adds the -n and -x build flags to the flag set.
+func AddBuildFlagsNX(flags *flag.FlagSet) {
+ flags.BoolVar(&BuildN, "n", false, "")
+ flags.BoolVar(&BuildX, "x", false, "")
+}