Otherwise, the behavior of 'go work use -r' (without arguments)
may be surprising.
Change-Id: I50cf1339591720ec5bd333146b89c9944ce420d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/389855
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
//
// Usage:
//
-// go work use [-r] [moddirs]
+// go work use [-r] moddirs
//
// Use provides a command-line interface for adding
// directories, optionally recursively, to a go.work file.
)
var cmdUse = &base.Command{
- UsageLine: "go work use [-r] [moddirs]",
+ UsageLine: "go work use [-r] moddirs",
Short: "add modules to workspace file",
Long: `Use provides a command-line interface for adding
directories, optionally recursively, to a go.work file.
keepDirs[absDir] = dir
}
+ if len(args) == 0 {
+ base.Fatalf("go: 'go work use' requires one or more directory arguments")
+ }
for _, useDir := range args {
if !*useR {
lookDir(useDir)
--- /dev/null
+# For now, 'go work use' requires arguments.
+# (Eventually, we may may it implicitly behave like 'go work use .'.
+
+! go work use
+stderr '^go: ''go work use'' requires one or more directory arguments'
+
+! go work use -r
+stderr '^go: ''go work use'' requires one or more directory arguments'
+
+-- go.work --
+go 1.18