mirror of
https://github.com/golang/go
synced 2024-11-25 00:07:56 -07:00
cmd/go: add tool -n flag
As in gdb $(go tool -n 6g). R=golang-dev, r CC=golang-dev https://golang.org/cl/5689066
This commit is contained in:
parent
6d35302704
commit
d1e1367cad
@ -17,12 +17,15 @@ import (
|
|||||||
|
|
||||||
var cmdTool = &Command{
|
var cmdTool = &Command{
|
||||||
Run: runTool,
|
Run: runTool,
|
||||||
UsageLine: "tool command [args...]",
|
UsageLine: "tool [-n] command [args...]",
|
||||||
Short: "run specified go tool",
|
Short: "run specified go tool",
|
||||||
Long: `
|
Long: `
|
||||||
Tool runs the go tool command identified by the arguments.
|
Tool runs the go tool command identified by the arguments.
|
||||||
With no arguments it prints the list of known tools.
|
With no arguments it prints the list of known tools.
|
||||||
|
|
||||||
|
The -n flag causes tool to print the command that would be
|
||||||
|
executed but not execute it.
|
||||||
|
|
||||||
For more about each tool command, see 'go tool command -h'.
|
For more about each tool command, see 'go tool command -h'.
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
@ -32,8 +35,14 @@ var (
|
|||||||
toolGOARCH = runtime.GOARCH
|
toolGOARCH = runtime.GOARCH
|
||||||
toolIsWindows = toolGOOS == "windows"
|
toolIsWindows = toolGOOS == "windows"
|
||||||
toolDir = build.ToolDir
|
toolDir = build.ToolDir
|
||||||
|
|
||||||
|
toolN bool
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdTool.Flag.BoolVar(&toolN, "n", false, "")
|
||||||
|
}
|
||||||
|
|
||||||
const toolWindowsExtension = ".exe"
|
const toolWindowsExtension = ".exe"
|
||||||
|
|
||||||
func tool(name string) string {
|
func tool(name string) string {
|
||||||
@ -67,6 +76,11 @@ func runTool(cmd *Command, args []string) {
|
|||||||
setExitStatus(3)
|
setExitStatus(3)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if toolN {
|
||||||
|
fmt.Printf("%s %s\n", toolPath, strings.Join(args[1:], " "))
|
||||||
|
return
|
||||||
|
}
|
||||||
toolCmd := &exec.Cmd{
|
toolCmd := &exec.Cmd{
|
||||||
Path: toolPath,
|
Path: toolPath,
|
||||||
Args: args,
|
Args: args,
|
||||||
|
Loading…
Reference in New Issue
Block a user