internal/cmd/deadcode: rename -format to -f

(following go list)

Change-Id: Ie87af973b853584082c298c339e995a8030f2d9b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/540475
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/internal/cmd/deadcode/deadcode.go b/internal/cmd/deadcode/deadcode.go
index 890fcc1..58b42c2 100644
--- a/internal/cmd/deadcode/deadcode.go
+++ b/internal/cmd/deadcode/deadcode.go
@@ -43,7 +43,7 @@
 	filterFlag    = flag.String("filter", "<module>", "report only packages matching this regular expression (default: module of first package)")
 	generatedFlag = flag.Bool("generated", false, "include dead functions in generated Go files")
 	whyLiveFlag   = flag.String("whylive", "", "show a path from main to the named function")
-	formatFlag    = flag.String("format", "", "format output records using template")
+	formatFlag    = flag.String("f", "", "format output records using template")
 	jsonFlag      = flag.Bool("json", false, "output JSON records")
 	cpuProfile    = flag.String("cpuprofile", "", "write CPU profile to this file")
 	memProfile    = flag.String("memprofile", "", "write memory profile to this file")
@@ -101,10 +101,10 @@
 	// Reject bad output options early.
 	if *formatFlag != "" {
 		if *jsonFlag {
-			log.Fatalf("you cannot specify both -format=template and -json")
+			log.Fatalf("you cannot specify both -f=template and -json")
 		}
 		if _, err := template.New("deadcode").Parse(*formatFlag); err != nil {
-			log.Fatalf("invalid -format: %v", err)
+			log.Fatalf("invalid -f: %v", err)
 		}
 	}
 
@@ -232,7 +232,7 @@
 		}
 
 		// Build a list of jsonEdge records
-		// to print as -json or -format=template.
+		// to print as -json or -f=template.
 		var edges []any
 		for _, edge := range path {
 			edges = append(edges, jsonEdge{
@@ -357,7 +357,7 @@
 		return
 	}
 
-	// -format=template. Parse can't fail: we checked it earlier.
+	// -f=template. Parse can't fail: we checked it earlier.
 	tmpl := template.Must(template.New("deadcode").Parse(format))
 	for _, object := range objects {
 		var buf bytes.Buffer
diff --git a/internal/cmd/deadcode/doc.go b/internal/cmd/deadcode/doc.go
index 3c0e711..8d28eb3 100644
--- a/internal/cmd/deadcode/doc.go
+++ b/internal/cmd/deadcode/doc.go
@@ -64,15 +64,15 @@
 With the -json flag, the command prints an array of Package
 objects, as defined by the JSON schema (see below).
 
-With the -format=template flag, the command executes the specified template
+With the -f=template flag, the command executes the specified template
 on each Package record. So, this template produces a result similar to the
 default format:
 
-	-format='{{println .Path}}{{range .Funcs}}{{printf "\t%s\n" .RelName}}{{end}}{{println}}'
+	-f='{{println .Path}}{{range .Funcs}}{{printf "\t%s\n" .RelName}}{{end}}{{println}}'
 
 And this template shows only the list of source positions of dead functions:
 
-	-format='{{range .Funcs}}{{println .Posn}}{{end}}'
+	-f='{{range .Funcs}}{{println .Posn}}{{end}}'
 
 # Why is a function not dead?
 
@@ -87,7 +87,7 @@
 preferred over paths from init functions.
 
 The result is a list of Edge objects (see JSON schema below).
-Again, the -json and -format=template flags may be used to control
+Again, the -json and -f=template flags may be used to control
 the formatting of the list of Edge objects.
 The default format shows, for each edge in the path, whether the call
 is static or dynamic, and its source line number. For example:
diff --git a/internal/cmd/deadcode/testdata/lineflag.txtar b/internal/cmd/deadcode/testdata/lineflag.txtar
index e629e05..51940ad 100644
--- a/internal/cmd/deadcode/testdata/lineflag.txtar
+++ b/internal/cmd/deadcode/testdata/lineflag.txtar
@@ -1,6 +1,6 @@
 # Test of line-oriented output.
 
- deadcode "-format={{range .Funcs}}{{println .Name}}{{end}}" -filter= example.com
+ deadcode "-f={{range .Funcs}}{{println .Name}}{{end}}" -filter= example.com
 
  want "(example.com.T).Goodbye"
 !want "(example.com.T).Hello"