2017-05-06 14:06:49 -05:00
|
|
|
// Package main is complete tool for the go command line
|
2017-05-05 10:01:27 -05:00
|
|
|
package main
|
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
import (
|
2021-04-06 06:23:51 -05:00
|
|
|
"io/ioutil"
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
|
2019-11-17 17:25:16 -06:00
|
|
|
"github.com/posener/complete/v2"
|
|
|
|
"github.com/posener/complete/v2/predict"
|
2019-11-13 22:51:44 -06:00
|
|
|
)
|
2017-05-05 10:01:27 -05:00
|
|
|
|
2021-04-06 06:23:51 -05:00
|
|
|
// envVerbose is the sys env var that controls error output verbosity.
|
|
|
|
const envVerbose = "GOCOMP_VERBOSE"
|
|
|
|
|
2017-05-06 11:08:47 -05:00
|
|
|
var (
|
2019-11-13 22:51:44 -06:00
|
|
|
ellipsis = predict.Set{"./..."}
|
2017-05-15 14:44:19 -05:00
|
|
|
anyPackage = complete.PredictFunc(predictPackages)
|
2019-11-13 22:51:44 -06:00
|
|
|
goFiles = predict.Files("*.go")
|
|
|
|
anyFile = predict.Files("*")
|
|
|
|
anyGo = predict.Or(goFiles, anyPackage, ellipsis)
|
2017-05-06 11:08:47 -05:00
|
|
|
)
|
2017-05-05 16:25:27 -05:00
|
|
|
|
|
|
|
func main() {
|
2021-04-06 06:23:51 -05:00
|
|
|
if os.Getenv(envVerbose) != "1" {
|
|
|
|
log.SetOutput(ioutil.Discard)
|
|
|
|
}
|
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
build := &complete.Command{
|
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"o": anyFile,
|
|
|
|
"i": predict.Nothing,
|
|
|
|
|
|
|
|
"a": predict.Nothing,
|
|
|
|
"n": predict.Nothing,
|
|
|
|
"p": predict.Something,
|
|
|
|
"race": predict.Nothing,
|
|
|
|
"msan": predict.Nothing,
|
|
|
|
"v": predict.Nothing,
|
|
|
|
"work": predict.Nothing,
|
|
|
|
"x": predict.Nothing,
|
|
|
|
"asmflags": predict.Something,
|
|
|
|
"buildmode": predict.Something,
|
|
|
|
"compiler": predict.Something,
|
|
|
|
"gccgoflags": predict.Set{"gccgo", "gc"},
|
|
|
|
"gcflags": predict.Something,
|
|
|
|
"installsuffix": predict.Something,
|
|
|
|
"ldflags": predict.Something,
|
|
|
|
"linkshared": predict.Nothing,
|
|
|
|
"pkgdir": anyPackage,
|
|
|
|
"tags": predict.Something,
|
|
|
|
"toolexec": predict.Something,
|
2017-05-05 10:01:27 -05:00
|
|
|
},
|
2017-05-12 16:17:48 -05:00
|
|
|
Args: anyGo,
|
2017-05-05 10:06:31 -05:00
|
|
|
}
|
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
run := &complete.Command{
|
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"exec": predict.Something,
|
2017-05-05 10:06:31 -05:00
|
|
|
},
|
2017-05-18 15:40:02 -05:00
|
|
|
Args: goFiles,
|
2017-05-05 10:06:31 -05:00
|
|
|
}
|
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
test := &complete.Command{
|
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"args": predict.Something,
|
|
|
|
"c": predict.Nothing,
|
|
|
|
"exec": predict.Something,
|
|
|
|
|
|
|
|
"bench": predictBenchmark,
|
|
|
|
"benchtime": predict.Something,
|
|
|
|
"count": predict.Something,
|
|
|
|
"cover": predict.Nothing,
|
|
|
|
"covermode": predict.Set{"set", "count", "atomic"},
|
|
|
|
"coverpkg": predict.Dirs("*"),
|
|
|
|
"cpu": predict.Something,
|
|
|
|
"run": predictTest,
|
|
|
|
"short": predict.Nothing,
|
|
|
|
"timeout": predict.Something,
|
|
|
|
|
|
|
|
"benchmem": predict.Nothing,
|
|
|
|
"blockprofile": predict.Files("*.out"),
|
|
|
|
"blockprofilerate": predict.Something,
|
|
|
|
"coverprofile": predict.Files("*.out"),
|
|
|
|
"cpuprofile": predict.Files("*.out"),
|
|
|
|
"memprofile": predict.Files("*.out"),
|
|
|
|
"memprofilerate": predict.Something,
|
|
|
|
"mutexprofile": predict.Files("*.out"),
|
|
|
|
"mutexprofilefraction": predict.Something,
|
|
|
|
"outputdir": predict.Dirs("*"),
|
|
|
|
"trace": predict.Files("*.out"),
|
2017-05-05 16:25:27 -05:00
|
|
|
},
|
2017-05-12 16:17:48 -05:00
|
|
|
Args: anyGo,
|
2017-05-05 16:25:27 -05:00
|
|
|
}
|
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
fmt := &complete.Command{
|
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"n": predict.Nothing,
|
|
|
|
"x": predict.Nothing,
|
2017-05-05 16:25:27 -05:00
|
|
|
},
|
2017-05-12 16:17:48 -05:00
|
|
|
Args: anyGo,
|
2017-05-05 16:25:27 -05:00
|
|
|
}
|
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
get := &complete.Command{
|
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"d": predict.Nothing,
|
|
|
|
"f": predict.Nothing,
|
|
|
|
"fix": predict.Nothing,
|
|
|
|
"insecure": predict.Nothing,
|
|
|
|
"t": predict.Nothing,
|
|
|
|
"u": predict.Nothing,
|
2017-05-05 16:25:27 -05:00
|
|
|
},
|
2017-05-12 16:17:48 -05:00
|
|
|
Args: anyGo,
|
2017-05-05 16:25:27 -05:00
|
|
|
}
|
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
generate := &complete.Command{
|
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"n": predict.Nothing,
|
|
|
|
"x": predict.Nothing,
|
|
|
|
"v": predict.Nothing,
|
|
|
|
"run": predict.Something,
|
2017-05-05 16:25:27 -05:00
|
|
|
},
|
2017-05-12 16:17:48 -05:00
|
|
|
Args: anyGo,
|
2017-05-05 16:25:27 -05:00
|
|
|
}
|
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
vet := &complete.Command{
|
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"n": predict.Nothing,
|
|
|
|
"x": predict.Nothing,
|
2017-05-05 16:25:27 -05:00
|
|
|
},
|
2017-05-12 16:17:48 -05:00
|
|
|
Args: anyGo,
|
2017-05-05 16:25:27 -05:00
|
|
|
}
|
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
list := &complete.Command{
|
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"e": predict.Nothing,
|
|
|
|
"f": predict.Something,
|
|
|
|
"json": predict.Nothing,
|
2017-05-05 16:25:27 -05:00
|
|
|
},
|
2019-11-13 22:51:44 -06:00
|
|
|
Args: predict.Or(anyPackage, ellipsis),
|
2017-05-05 16:25:27 -05:00
|
|
|
}
|
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
doc := &complete.Command{
|
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"c": predict.Nothing,
|
|
|
|
"cmd": predict.Nothing,
|
|
|
|
"u": predict.Nothing,
|
2017-05-26 07:40:34 -05:00
|
|
|
},
|
|
|
|
Args: anyPackage,
|
|
|
|
}
|
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
tool := &complete.Command{
|
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"n": predict.Nothing,
|
2017-05-05 16:25:27 -05:00
|
|
|
},
|
2019-11-13 22:51:44 -06:00
|
|
|
Sub: map[string]*complete.Command{
|
2017-05-26 07:40:34 -05:00
|
|
|
"addr2line": {
|
|
|
|
Args: anyFile,
|
|
|
|
},
|
|
|
|
"asm": {
|
2019-11-13 22:51:44 -06:00
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"D": predict.Something,
|
|
|
|
"I": predict.Dirs("*"),
|
|
|
|
"S": predict.Nothing,
|
|
|
|
"V": predict.Nothing,
|
|
|
|
"debug": predict.Nothing,
|
|
|
|
"dynlink": predict.Nothing,
|
|
|
|
"e": predict.Nothing,
|
|
|
|
"o": anyFile,
|
|
|
|
"shared": predict.Nothing,
|
|
|
|
"trimpath": predict.Nothing,
|
2017-05-26 07:40:34 -05:00
|
|
|
},
|
2019-11-13 22:51:44 -06:00
|
|
|
Args: predict.Files("*.s"),
|
2017-05-26 07:40:34 -05:00
|
|
|
},
|
|
|
|
"cgo": {
|
2019-11-13 22:51:44 -06:00
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"debug-define": predict.Nothing,
|
|
|
|
"debug-gcc": predict.Nothing,
|
2017-05-26 07:40:34 -05:00
|
|
|
"dynimport": anyFile,
|
2019-11-13 22:51:44 -06:00
|
|
|
"dynlinker": predict.Nothing,
|
2017-05-26 07:40:34 -05:00
|
|
|
"dynout": anyFile,
|
|
|
|
"dynpackage": anyPackage,
|
2019-11-13 22:51:44 -06:00
|
|
|
"exportheader": predict.Dirs("*"),
|
|
|
|
"gccgo": predict.Nothing,
|
|
|
|
"gccgopkgpath": predict.Dirs("*"),
|
|
|
|
"gccgoprefix": predict.Something,
|
|
|
|
"godefs": predict.Nothing,
|
|
|
|
"import_runtime_cgo": predict.Nothing,
|
|
|
|
"import_syscall": predict.Nothing,
|
|
|
|
"importpath": predict.Dirs("*"),
|
|
|
|
"objdir": predict.Dirs("*"),
|
|
|
|
"srcdir": predict.Dirs("*"),
|
2017-05-26 07:40:34 -05:00
|
|
|
},
|
|
|
|
Args: goFiles,
|
|
|
|
},
|
|
|
|
"compile": {
|
2019-11-13 22:51:44 -06:00
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"%": predict.Nothing,
|
|
|
|
"+": predict.Nothing,
|
|
|
|
"B": predict.Nothing,
|
|
|
|
"D": predict.Dirs("*"),
|
|
|
|
"E": predict.Nothing,
|
|
|
|
"I": predict.Dirs("*"),
|
|
|
|
"K": predict.Nothing,
|
|
|
|
"N": predict.Nothing,
|
|
|
|
"S": predict.Nothing,
|
|
|
|
"V": predict.Nothing,
|
|
|
|
"W": predict.Nothing,
|
|
|
|
"asmhdr": anyFile,
|
|
|
|
"bench": anyFile,
|
|
|
|
"buildid": predict.Nothing,
|
|
|
|
"complete": predict.Nothing,
|
|
|
|
"cpuprofile": anyFile,
|
|
|
|
"d": predict.Nothing,
|
|
|
|
"dynlink": predict.Nothing,
|
|
|
|
"e": predict.Nothing,
|
|
|
|
"f": predict.Nothing,
|
|
|
|
"h": predict.Nothing,
|
|
|
|
"i": predict.Nothing,
|
|
|
|
"importmap": predict.Something,
|
|
|
|
"installsuffix": predict.Something,
|
|
|
|
"j": predict.Nothing,
|
|
|
|
"l": predict.Nothing,
|
|
|
|
"largemodel": predict.Nothing,
|
|
|
|
"linkobj": anyFile,
|
|
|
|
"live": predict.Nothing,
|
|
|
|
"m": predict.Nothing,
|
|
|
|
"memprofile": predict.Nothing,
|
|
|
|
"memprofilerate": predict.Something,
|
|
|
|
"msan": predict.Nothing,
|
|
|
|
"nolocalimports": predict.Nothing,
|
|
|
|
"o": anyFile,
|
|
|
|
"p": predict.Dirs("*"),
|
|
|
|
"pack": predict.Nothing,
|
|
|
|
"r": predict.Nothing,
|
|
|
|
"race": predict.Nothing,
|
|
|
|
"s": predict.Nothing,
|
|
|
|
"shared": predict.Nothing,
|
|
|
|
"traceprofile": anyFile,
|
|
|
|
"trimpath": predict.Something,
|
|
|
|
"u": predict.Nothing,
|
|
|
|
"v": predict.Nothing,
|
|
|
|
"w": predict.Nothing,
|
|
|
|
"wb": predict.Nothing,
|
2017-05-26 07:40:34 -05:00
|
|
|
},
|
|
|
|
Args: goFiles,
|
|
|
|
},
|
|
|
|
"cover": {
|
2019-11-13 22:51:44 -06:00
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"func": predict.Something,
|
|
|
|
"html": predict.Something,
|
|
|
|
"mode": predict.Set{"set", "count", "atomic"},
|
|
|
|
"o": anyFile,
|
|
|
|
"var": predict.Something,
|
2017-05-26 07:40:34 -05:00
|
|
|
},
|
|
|
|
Args: anyFile,
|
|
|
|
},
|
|
|
|
"dist": {
|
2019-11-13 22:51:44 -06:00
|
|
|
Sub: map[string]*complete.Command{
|
|
|
|
"banner": {Flags: map[string]complete.Predictor{"v": predict.Nothing}},
|
|
|
|
"bootstrap": {Flags: map[string]complete.Predictor{"v": predict.Nothing}},
|
|
|
|
"clean": {Flags: map[string]complete.Predictor{"v": predict.Nothing}},
|
|
|
|
"env": {Flags: map[string]complete.Predictor{"v": predict.Nothing, "p": predict.Nothing}},
|
|
|
|
"install": {Flags: map[string]complete.Predictor{"v": predict.Nothing}, Args: predict.Dirs("*")},
|
|
|
|
"list": {Flags: map[string]complete.Predictor{"v": predict.Nothing, "json": predict.Nothing}},
|
|
|
|
"test": {Flags: map[string]complete.Predictor{"v": predict.Nothing, "h": predict.Nothing}},
|
|
|
|
"version": {Flags: map[string]complete.Predictor{"v": predict.Nothing}},
|
2017-05-26 07:40:34 -05:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"doc": doc,
|
|
|
|
"fix": {
|
2019-11-13 22:51:44 -06:00
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"diff": predict.Nothing,
|
|
|
|
"force": predict.Something,
|
|
|
|
"r": predict.Set{"context", "gotypes", "netipv6zone", "printerconfig"},
|
2017-05-26 07:40:34 -05:00
|
|
|
},
|
|
|
|
Args: anyGo,
|
|
|
|
},
|
2018-04-10 01:32:35 -05:00
|
|
|
"link": {
|
2019-11-13 22:51:44 -06:00
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"B": predict.Something, // note
|
|
|
|
"D": predict.Something, // address (default -1)
|
|
|
|
"E": predict.Something, // entry symbol name
|
|
|
|
"H": predict.Something, // header type
|
|
|
|
"I": predict.Something, // linker binary
|
|
|
|
"L": predict.Dirs("*"), // directory
|
|
|
|
"R": predict.Something, // quantum (default -1)
|
|
|
|
"T": predict.Something, // address (default -1)
|
|
|
|
"V": predict.Nothing,
|
|
|
|
"X": predict.Something,
|
|
|
|
"a": predict.Something,
|
|
|
|
"buildid": predict.Something, // build id
|
|
|
|
"buildmode": predict.Something,
|
|
|
|
"c": predict.Nothing,
|
|
|
|
"cpuprofile": anyFile,
|
|
|
|
"d": predict.Nothing,
|
|
|
|
"debugtramp": predict.Something, // int
|
|
|
|
"dumpdep": predict.Nothing,
|
|
|
|
"extar": predict.Something,
|
|
|
|
"extld": predict.Something,
|
|
|
|
"extldflags": predict.Something, // flags
|
|
|
|
"f": predict.Nothing,
|
|
|
|
"g": predict.Nothing,
|
|
|
|
"importcfg": anyFile,
|
|
|
|
"installsuffix": predict.Something, // dir suffix
|
|
|
|
"k": predict.Something, // symbol
|
|
|
|
"libgcc": predict.Something, // maybe "none"
|
|
|
|
"linkmode": predict.Something, // mode
|
|
|
|
"linkshared": predict.Nothing,
|
|
|
|
"memprofile": anyFile,
|
|
|
|
"memprofilerate": predict.Something, // rate
|
|
|
|
"msan": predict.Nothing,
|
|
|
|
"n": predict.Nothing,
|
|
|
|
"o": predict.Something,
|
|
|
|
"pluginpath": predict.Something,
|
|
|
|
"r": predict.Something, // "dir1:dir2:..."
|
|
|
|
"race": predict.Nothing,
|
|
|
|
"s": predict.Nothing,
|
|
|
|
"tmpdir": predict.Dirs("*"),
|
|
|
|
"u": predict.Nothing,
|
|
|
|
"v": predict.Nothing,
|
|
|
|
"w": predict.Nothing,
|
|
|
|
// "h": predict.Something, // halt on error
|
2018-04-10 01:32:35 -05:00
|
|
|
},
|
2019-11-13 22:51:44 -06:00
|
|
|
Args: predict.Or(
|
|
|
|
predict.Files("*.a"),
|
|
|
|
predict.Files("*.o"),
|
2018-04-10 01:32:35 -05:00
|
|
|
),
|
|
|
|
},
|
2017-05-26 07:40:34 -05:00
|
|
|
"nm": {
|
2019-11-13 22:51:44 -06:00
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"n": predict.Nothing,
|
|
|
|
"size": predict.Nothing,
|
|
|
|
"sort": predict.Something,
|
|
|
|
"type": predict.Nothing,
|
2017-05-26 07:40:34 -05:00
|
|
|
},
|
|
|
|
Args: anyGo,
|
|
|
|
},
|
|
|
|
"objdump": {
|
2019-11-13 22:51:44 -06:00
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"s": predict.Something,
|
|
|
|
"S": predict.Nothing,
|
2017-05-26 07:40:34 -05:00
|
|
|
},
|
|
|
|
Args: anyFile,
|
|
|
|
},
|
2018-04-10 01:31:31 -05:00
|
|
|
"pack": {
|
|
|
|
/* this lacks the positional aspect of all these params */
|
2019-11-13 22:51:44 -06:00
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"c": predict.Nothing,
|
|
|
|
"p": predict.Nothing,
|
|
|
|
"r": predict.Nothing,
|
|
|
|
"t": predict.Nothing,
|
|
|
|
"x": predict.Nothing,
|
|
|
|
"cv": predict.Nothing,
|
|
|
|
"pv": predict.Nothing,
|
|
|
|
"rv": predict.Nothing,
|
|
|
|
"tv": predict.Nothing,
|
|
|
|
"xv": predict.Nothing,
|
2018-04-10 01:31:31 -05:00
|
|
|
},
|
2019-11-13 22:51:44 -06:00
|
|
|
Args: predict.Or(
|
|
|
|
predict.Files("*.a"),
|
|
|
|
predict.Files("*.o"),
|
2018-04-10 01:31:31 -05:00
|
|
|
),
|
|
|
|
},
|
2017-05-26 07:40:34 -05:00
|
|
|
"pprof": {
|
2019-11-13 22:51:44 -06:00
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"callgrind": predict.Nothing,
|
|
|
|
"disasm": predict.Something,
|
|
|
|
"dot": predict.Nothing,
|
|
|
|
"eog": predict.Nothing,
|
|
|
|
"evince": predict.Nothing,
|
|
|
|
"gif": predict.Nothing,
|
|
|
|
"gv": predict.Nothing,
|
|
|
|
"list": predict.Something,
|
|
|
|
"pdf": predict.Nothing,
|
|
|
|
"peek": predict.Something,
|
|
|
|
"png": predict.Nothing,
|
|
|
|
"proto": predict.Nothing,
|
|
|
|
"ps": predict.Nothing,
|
|
|
|
"raw": predict.Nothing,
|
|
|
|
"svg": predict.Nothing,
|
|
|
|
"tags": predict.Nothing,
|
|
|
|
"text": predict.Nothing,
|
|
|
|
"top": predict.Nothing,
|
|
|
|
"tree": predict.Nothing,
|
|
|
|
"web": predict.Nothing,
|
|
|
|
"weblist": predict.Something,
|
|
|
|
"output": anyFile,
|
|
|
|
"functions": predict.Nothing,
|
|
|
|
"files": predict.Nothing,
|
|
|
|
"lines": predict.Nothing,
|
|
|
|
"addresses": predict.Nothing,
|
|
|
|
"base": predict.Something,
|
|
|
|
"drop_negative": predict.Nothing,
|
|
|
|
"cum": predict.Nothing,
|
|
|
|
"seconds": predict.Something,
|
|
|
|
"nodecount": predict.Something,
|
|
|
|
"nodefraction": predict.Something,
|
|
|
|
"edgefraction": predict.Something,
|
|
|
|
"sample_index": predict.Nothing,
|
|
|
|
"mean": predict.Nothing,
|
|
|
|
"inuse_space": predict.Nothing,
|
|
|
|
"inuse_objects": predict.Nothing,
|
|
|
|
"alloc_space": predict.Nothing,
|
|
|
|
"alloc_objects": predict.Nothing,
|
|
|
|
"total_delay": predict.Nothing,
|
|
|
|
"contentions": predict.Nothing,
|
|
|
|
"mean_delay": predict.Nothing,
|
|
|
|
"runtime": predict.Nothing,
|
|
|
|
"focus": predict.Something,
|
|
|
|
"ignore": predict.Something,
|
|
|
|
"tagfocus": predict.Something,
|
|
|
|
"tagignore": predict.Something,
|
|
|
|
"call_tree": predict.Nothing,
|
|
|
|
"unit": predict.Something,
|
|
|
|
"divide_by": predict.Something,
|
|
|
|
"buildid": predict.Something,
|
|
|
|
"tools": predict.Dirs("*"),
|
|
|
|
"help": predict.Nothing,
|
2017-05-26 07:40:34 -05:00
|
|
|
},
|
|
|
|
Args: anyFile,
|
|
|
|
},
|
|
|
|
"tour": {
|
2019-11-13 22:51:44 -06:00
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"http": predict.Something,
|
|
|
|
"openbrowser": predict.Nothing,
|
2017-05-26 07:40:34 -05:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"trace": {
|
2019-11-13 22:51:44 -06:00
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"http": predict.Something,
|
|
|
|
"pprof": predict.Set{"net", "sync", "syscall", "sched"},
|
2017-05-26 07:40:34 -05:00
|
|
|
},
|
|
|
|
Args: anyFile,
|
|
|
|
},
|
|
|
|
"vet": {
|
2019-11-13 22:51:44 -06:00
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"all": predict.Nothing,
|
|
|
|
"asmdecl": predict.Nothing,
|
|
|
|
"assign": predict.Nothing,
|
|
|
|
"atomic": predict.Nothing,
|
|
|
|
"bool": predict.Nothing,
|
|
|
|
"buildtags": predict.Nothing,
|
|
|
|
"cgocall": predict.Nothing,
|
|
|
|
"composites": predict.Nothing,
|
|
|
|
"compositewhitelist": predict.Nothing,
|
|
|
|
"copylocks": predict.Nothing,
|
|
|
|
"httpresponse": predict.Nothing,
|
|
|
|
"lostcancel": predict.Nothing,
|
|
|
|
"methods": predict.Nothing,
|
|
|
|
"nilfunc": predict.Nothing,
|
|
|
|
"printf": predict.Nothing,
|
|
|
|
"printfuncs": predict.Something,
|
|
|
|
"rangeloops": predict.Nothing,
|
|
|
|
"shadow": predict.Nothing,
|
|
|
|
"shadowstrict": predict.Nothing,
|
|
|
|
"shift": predict.Nothing,
|
|
|
|
"structtags": predict.Nothing,
|
|
|
|
"tags": predict.Something,
|
|
|
|
"tests": predict.Nothing,
|
|
|
|
"unreachable": predict.Nothing,
|
|
|
|
"unsafeptr": predict.Nothing,
|
|
|
|
"unusedfuncs": predict.Something,
|
|
|
|
"unusedresult": predict.Nothing,
|
|
|
|
"unusedstringmethods": predict.Something,
|
|
|
|
"v": predict.Nothing,
|
2017-05-26 07:40:34 -05:00
|
|
|
},
|
|
|
|
Args: anyGo,
|
|
|
|
},
|
|
|
|
},
|
2017-05-05 16:25:27 -05:00
|
|
|
}
|
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
clean := &complete.Command{
|
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"i": predict.Nothing,
|
|
|
|
"r": predict.Nothing,
|
|
|
|
"n": predict.Nothing,
|
|
|
|
"x": predict.Nothing,
|
|
|
|
"cache": predict.Nothing,
|
|
|
|
"testcache": predict.Nothing,
|
|
|
|
"modcache": predict.Nothing,
|
2017-05-05 16:25:27 -05:00
|
|
|
},
|
2019-11-13 22:51:44 -06:00
|
|
|
Args: predict.Or(anyPackage, ellipsis),
|
2017-05-05 16:25:27 -05:00
|
|
|
}
|
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
env := &complete.Command{
|
|
|
|
Args: predict.Something,
|
2017-05-05 16:25:27 -05:00
|
|
|
}
|
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
bug := &complete.Command{}
|
|
|
|
version := &complete.Command{}
|
2017-05-05 16:25:27 -05:00
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
fix := &complete.Command{
|
2017-05-12 16:17:48 -05:00
|
|
|
Args: anyGo,
|
2017-05-05 16:25:27 -05:00
|
|
|
}
|
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
modDownload := &complete.Command{
|
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"json": predict.Nothing,
|
2018-08-27 14:59:20 -05:00
|
|
|
},
|
|
|
|
Args: anyPackage,
|
|
|
|
}
|
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
modEdit := &complete.Command{
|
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"fmt": predict.Nothing,
|
|
|
|
"module": predict.Nothing,
|
|
|
|
"print": predict.Nothing,
|
|
|
|
|
|
|
|
"exclude": anyPackage,
|
|
|
|
"dropexclude": anyPackage,
|
|
|
|
"replace": anyPackage,
|
|
|
|
"dropreplace": anyPackage,
|
|
|
|
"require": anyPackage,
|
|
|
|
"droprequire": anyPackage,
|
2018-08-27 14:59:20 -05:00
|
|
|
},
|
2019-11-13 22:51:44 -06:00
|
|
|
Args: predict.Files("go.mod"),
|
2018-08-27 14:59:20 -05:00
|
|
|
}
|
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
modGraph := &complete.Command{}
|
2018-08-27 14:59:20 -05:00
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
modInit := &complete.Command{
|
|
|
|
Args: predict.Something,
|
2018-08-27 14:59:20 -05:00
|
|
|
}
|
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
modTidy := &complete.Command{
|
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"v": predict.Nothing,
|
2018-08-27 14:59:20 -05:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
modVendor := &complete.Command{
|
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"v": predict.Nothing,
|
2018-08-27 14:59:20 -05:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
modVerify := &complete.Command{}
|
2018-08-27 14:59:20 -05:00
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
modWhy := &complete.Command{
|
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"m": predict.Nothing,
|
|
|
|
"vendor": predict.Nothing,
|
2018-08-27 14:59:20 -05:00
|
|
|
},
|
|
|
|
Args: anyPackage,
|
|
|
|
}
|
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
modHelp := &complete.Command{
|
|
|
|
Sub: map[string]*complete.Command{
|
2021-01-30 03:13:29 -06:00
|
|
|
"download": {},
|
|
|
|
"edit": {},
|
|
|
|
"graph": {},
|
|
|
|
"init": {},
|
|
|
|
"tidy": {},
|
|
|
|
"vendor": {},
|
|
|
|
"verify": {},
|
|
|
|
"why": {},
|
2018-08-27 14:59:20 -05:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
mod := &complete.Command{
|
|
|
|
Sub: map[string]*complete.Command{
|
2018-08-27 14:59:20 -05:00
|
|
|
"download": modDownload,
|
|
|
|
"edit": modEdit,
|
|
|
|
"graph": modGraph,
|
|
|
|
"init": modInit,
|
|
|
|
"tidy": modTidy,
|
|
|
|
"vendor": modVendor,
|
|
|
|
"verify": modVerify,
|
|
|
|
"why": modWhy,
|
|
|
|
"help": modHelp,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
help := &complete.Command{
|
|
|
|
Sub: map[string]*complete.Command{
|
2021-01-30 03:13:29 -06:00
|
|
|
"bug": {},
|
|
|
|
"build": {},
|
|
|
|
"clean": {},
|
|
|
|
"doc": {},
|
|
|
|
"env": {},
|
|
|
|
"fix": {},
|
|
|
|
"fmt": {},
|
|
|
|
"generate": {},
|
|
|
|
"get": {},
|
|
|
|
"install": {},
|
|
|
|
"list": {},
|
2018-08-27 14:59:20 -05:00
|
|
|
"mod": modHelp,
|
2021-01-30 03:13:29 -06:00
|
|
|
"run": {},
|
|
|
|
"test": {},
|
|
|
|
"tool": {},
|
|
|
|
"version": {},
|
|
|
|
"vet": {},
|
|
|
|
"buildmode": {},
|
|
|
|
"c": {},
|
|
|
|
"cache": {},
|
|
|
|
"environment": {},
|
|
|
|
"filetype": {},
|
|
|
|
"go.mod": {},
|
|
|
|
"gopath": {},
|
|
|
|
"gopath-get": {},
|
|
|
|
"goproxy": {},
|
|
|
|
"importpath": {},
|
|
|
|
"modules": {},
|
|
|
|
"module-get": {},
|
|
|
|
"packages": {},
|
|
|
|
"testflag": {},
|
|
|
|
"testfunc": {},
|
2018-08-27 14:59:20 -05:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2017-05-05 16:25:27 -05:00
|
|
|
// commands that also accepts the build flags
|
|
|
|
for name, options := range build.Flags {
|
|
|
|
test.Flags[name] = options
|
|
|
|
run.Flags[name] = options
|
|
|
|
list.Flags[name] = options
|
|
|
|
vet.Flags[name] = options
|
2017-05-15 08:37:36 -05:00
|
|
|
get.Flags[name] = options
|
2017-05-05 16:25:27 -05:00
|
|
|
}
|
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
gogo := &complete.Command{
|
|
|
|
Sub: map[string]*complete.Command{
|
2017-05-05 16:25:27 -05:00
|
|
|
"build": build,
|
|
|
|
"install": build, // install and build have the same flags
|
|
|
|
"run": run,
|
|
|
|
"test": test,
|
|
|
|
"fmt": fmt,
|
|
|
|
"get": get,
|
|
|
|
"generate": generate,
|
|
|
|
"vet": vet,
|
|
|
|
"list": list,
|
2017-05-26 07:40:34 -05:00
|
|
|
"doc": doc,
|
2017-05-05 16:25:27 -05:00
|
|
|
"tool": tool,
|
|
|
|
"clean": clean,
|
|
|
|
"env": env,
|
|
|
|
"bug": bug,
|
|
|
|
"fix": fix,
|
|
|
|
"version": version,
|
2018-08-27 14:59:20 -05:00
|
|
|
"mod": mod,
|
|
|
|
"help": help,
|
2017-05-05 10:01:27 -05:00
|
|
|
},
|
2019-11-13 22:51:44 -06:00
|
|
|
Flags: map[string]complete.Predictor{
|
|
|
|
"h": predict.Nothing,
|
2017-05-05 10:06:31 -05:00
|
|
|
},
|
|
|
|
}
|
2017-05-05 10:01:27 -05:00
|
|
|
|
2019-11-13 22:51:44 -06:00
|
|
|
gogo.Complete("go")
|
2017-05-05 10:01:27 -05:00
|
|
|
}
|