1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
// -*- go -*-
////////////////////////////////////////////////////////////////////////////
// Program: gogo
// Purpose: Golang package manager
////////////////////////////////////////////////////////////////////////////
package main
import (
"github.com/mkideal/cli"
)
var app = &cli.Register(&cli.Command{
Name: "gogo",
Desc: "Golang package manager",
Text: " gogo is a new golang package manager\n very very good",
Argv: func() interface{} { return new(gogoT) },
Fn: gogo,
NumArg: cli.ExactN(1),
})
type gogoT struct {
cli.Helper
Version bool `cli:"v,version" usage:"display version"`
List bool `cli:"l,list" usage:"list all sub commands or not"`
}
func gogo(ctx *cli.Context) error {
argv := ctx.Argv().(*gogoT)
ctx.String("%s: %v", ctx.Path(), jsonIndent(argv))
ctx.String("[gogo]: %v\n", ctx.Args())
return nil
}
////////////////////////////////////////////////////////////////////////////
// Program: build
// Purpose: Build golang application
////////////////////////////////////////////////////////////////////////////
package main
import (
"github.com/mkideal/cli"
)
var buildCmd = app.Register(&cli.Command{
Name: "build",
Desc: "Build golang application",
Text: "Usage:\n gogo build [Options] Arch(i386|amd64)",
Argv: func() interface{} { return new(buildT) },
Fn: build,
NumArg: cli.ExactN(1),
CanSubRoute: true,
})
type buildT struct {
cli.Helper
Dir string `cli:"dir" usage:"source code root dir" dft:"./"`
Suffix string `cli:"suffix" usage:"source file suffix" dft:".go,.c,.s"`
Out string `cli:"o,out" usage:"output filename"`
}
func build(ctx *cli.Context) error {
argv := ctx.Argv().(*buildT)
ctx.String("%s: %v", ctx.Path(), jsonIndent(argv))
ctx.String("[build]: %v\n", ctx.Args())
return nil
}
////////////////////////////////////////////////////////////////////////////
// Program: install
// Purpose: Install golang application
////////////////////////////////////////////////////////////////////////////
package main
import (
"github.com/mkideal/cli"
)
var installCmd = app.Register(&cli.Command{
Name: "install",
Desc: "Install golang application",
Text: "Usage:\n gogo install [Options] package [package...]",
Argv: func() interface{} { return new(installT) },
Fn: install,
NumArg: cli.AtLeast(1),
CanSubRoute: true,
})
type installT struct {
cli.Helper
Dir string `cli:"dir" usage:"source code root dir" dft:"./"`
Suffix string `cli:"suffix" usage:"source file suffix" dft:".go,.c,.s"`
Out string `cli:"o,out" usage:"output filename"`
}
func install(ctx *cli.Context) error {
argv := ctx.Argv().(*installT)
ctx.String("%s: %v", ctx.Path(), jsonIndent(argv))
ctx.String("[install]: %v\n", ctx.Args())
return nil
}
////////////////////////////////////////////////////////////////////////////
// Program: publish
// Purpose: Publish golang application
////////////////////////////////////////////////////////////////////////////
package main
import (
"github.com/mkideal/cli"
)
var publishCmd = app.Register(&cli.Command{
Name: "publish",
Desc: "Publish golang application",
Argv: func() interface{} { return new(publishT) },
Fn: publish,
})
type publishT struct {
cli.Helper
Dir string `cli:"dir" usage:"source code root dir" dft:"./"`
Suffix string `cli:"suffix" usage:"source file suffix" dft:".go,.c,.s"`
Out string `cli:"o,out" usage:"output filename"`
List bool `cli:"l,list" usage:"list all sub commands"`
}
func publish(ctx *cli.Context) error {
argv := ctx.Argv().(*publishT)
ctx.String("%s: %v", ctx.Path(), jsonIndent(argv))
ctx.String("[publish]: %v\n", ctx.Args())
return nil
}
|