diff options
Diffstat (limited to 'src/cmd/dist/main.c')
-rw-r--r-- | src/cmd/dist/main.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/cmd/dist/main.c b/src/cmd/dist/main.c new file mode 100644 index 000000000..72a7579d1 --- /dev/null +++ b/src/cmd/dist/main.c @@ -0,0 +1,41 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#include "a.h" + +int vflag; +char *argv0; + +// cmdtab records the available commands. +static struct { + char *name; + void (*f)(int, char**); +} cmdtab[] = { + {"banner", cmdbanner}, + {"bootstrap", cmdbootstrap}, + {"clean", cmdclean}, + {"env", cmdenv}, + {"install", cmdinstall}, + {"version", cmdversion}, +}; + +// The OS-specific main calls into the portable code here. +void +xmain(int argc, char **argv) +{ + int i; + + if(argc <= 1) + usage(); + + for(i=0; i<nelem(cmdtab); i++) { + if(streq(cmdtab[i].name, argv[1])) { + cmdtab[i].f(argc-1, argv+1); + return; + } + } + + xprintf("unknown command %s\n", argv[1]); + usage(); +} |