mirror of
https://github.com/golang/go
synced 2024-11-18 08:54:45 -07:00
x/tools/*: print program name, not "Error", when reporting command error messages.
Such messages are more informative when the error occurs deep within a script. Also: add tool name to digraph's usage messages. LGTM=gri R=gri CC=golang-codereviews https://golang.org/cl/173380043
This commit is contained in:
parent
0ae83e44ba
commit
4162082cba
@ -134,7 +134,7 @@ func init() {
|
||||
func main() {
|
||||
flag.Parse()
|
||||
if err := doCallgraph(&build.Default, *algoFlag, *formatFlag, *testFlag, flag.Args()); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "callgraph: %s.\n", err)
|
||||
fmt.Fprintf(os.Stderr, "callgraph: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ func main() {
|
||||
}
|
||||
|
||||
if err := digraph(args[0], args[1:]); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %s\n", err)
|
||||
fmt.Fprintf(os.Stderr, "digraph: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
@ -265,7 +265,7 @@ func digraph(cmd string, args []string) error {
|
||||
switch cmd {
|
||||
case "nodes":
|
||||
if len(args) != 0 {
|
||||
return fmt.Errorf("usage: nodes")
|
||||
return fmt.Errorf("usage: digraph nodes")
|
||||
}
|
||||
nodes := make(nodeset)
|
||||
for label := range g {
|
||||
@ -275,7 +275,7 @@ func digraph(cmd string, args []string) error {
|
||||
|
||||
case "degree":
|
||||
if len(args) != 0 {
|
||||
return fmt.Errorf("usage: degree")
|
||||
return fmt.Errorf("usage: digraph degree")
|
||||
}
|
||||
nodes := make(nodeset)
|
||||
for label := range g {
|
||||
@ -288,7 +288,7 @@ func digraph(cmd string, args []string) error {
|
||||
|
||||
case "succs", "preds":
|
||||
if len(args) == 0 {
|
||||
return fmt.Errorf("usage: %s <label> ...", cmd)
|
||||
return fmt.Errorf("usage: digraph %s <label> ...", cmd)
|
||||
}
|
||||
g := g
|
||||
if cmd == "preds" {
|
||||
@ -306,7 +306,7 @@ func digraph(cmd string, args []string) error {
|
||||
|
||||
case "forward", "reverse":
|
||||
if len(args) == 0 {
|
||||
return fmt.Errorf("usage: %s <label> ...", cmd)
|
||||
return fmt.Errorf("usage: digraph %s <label> ...", cmd)
|
||||
}
|
||||
roots := make(nodeset)
|
||||
for _, root := range args {
|
||||
@ -323,7 +323,7 @@ func digraph(cmd string, args []string) error {
|
||||
|
||||
case "somepath":
|
||||
if len(args) != 2 {
|
||||
return fmt.Errorf("usage: somepath <from> <to>")
|
||||
return fmt.Errorf("usage: digraph somepath <from> <to>")
|
||||
}
|
||||
from, to := args[0], args[1]
|
||||
if g[from] == nil {
|
||||
@ -356,7 +356,7 @@ func digraph(cmd string, args []string) error {
|
||||
|
||||
case "allpaths":
|
||||
if len(args) != 2 {
|
||||
return fmt.Errorf("usage: allpaths <from> <to>")
|
||||
return fmt.Errorf("usage: digraph allpaths <from> <to>")
|
||||
}
|
||||
from, to := args[0], args[1]
|
||||
if g[from] == nil {
|
||||
@ -395,7 +395,7 @@ func digraph(cmd string, args []string) error {
|
||||
|
||||
case "sccs":
|
||||
if len(args) != 0 {
|
||||
return fmt.Errorf("usage: sccs")
|
||||
return fmt.Errorf("usage: digraph sccs")
|
||||
}
|
||||
for _, scc := range g.sccs() {
|
||||
scc.sort().println(" ")
|
||||
@ -403,7 +403,7 @@ func digraph(cmd string, args []string) error {
|
||||
|
||||
case "scc":
|
||||
if len(args) != 1 {
|
||||
return fmt.Errorf("usage: scc <label>")
|
||||
return fmt.Errorf("usage: digraph scc <label>")
|
||||
}
|
||||
label := args[0]
|
||||
if g[label] == nil {
|
||||
|
@ -11,7 +11,6 @@ import (
|
||||
"go/token"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/tools/go/loader"
|
||||
@ -37,7 +36,7 @@ Usage: eg -t template.go [-w] [-transitive] <args>...
|
||||
|
||||
func main() {
|
||||
if err := doMain(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%s: %s.\n", filepath.Base(os.Args[0]), err)
|
||||
fmt.Fprintf(os.Stderr, "eg: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
@ -128,7 +127,7 @@ func doMain() error {
|
||||
}
|
||||
}
|
||||
if err := eg.WriteAST(iprog.Fset, filename, file); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %s\n", err)
|
||||
fmt.Fprintf(os.Stderr, "eg: %s\n", err)
|
||||
hadErrors = true
|
||||
}
|
||||
} else {
|
||||
|
@ -120,7 +120,7 @@ Features:
|
||||
func main() {
|
||||
flag.Parse()
|
||||
if len(flag.Args()) > 0 {
|
||||
fmt.Fprintf(os.Stderr, "Error: surplus arguments.\n")
|
||||
fmt.Fprintln(os.Stderr, "gorename: surplus arguments.")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ func main() {
|
||||
|
||||
if err := rename.Main(&build.Default, *offsetFlag, *fromFlag, *toFlag); err != nil {
|
||||
if err != rename.ConflictError {
|
||||
fmt.Fprintf(os.Stderr, "Error: %s.\n", err)
|
||||
fmt.Fprintf(os.Stderr, "gorename: %s\n", err)
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ func init() {
|
||||
|
||||
func main() {
|
||||
if err := doMain(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "ssadump: %s.\n", err)
|
||||
fmt.Fprintf(os.Stderr, "ssadump: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ func (r *renamer) update() error {
|
||||
}
|
||||
}
|
||||
if err := rewriteFile(r.iprog.Fset, f, tokenFile.Name()); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %s.\n", err)
|
||||
fmt.Fprintf(os.Stderr, "gorename: %s\n", err)
|
||||
nerrs++
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user