本文整理汇总了Golang中github.com/codegangsta/cli.NewApp函数的典型用法代码示例。如果您正苦于以下问题:Golang NewApp函数的具体用法?Golang NewApp怎么用?Golang NewApp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewApp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Test_glob_opts
func Test_glob_opts(t *testing.T) {
{
app := cli.NewApp()
var our_wc watch.Config
app.Flags = global_flags(&our_wc)
is := make_is(t)
app.Run([]string{""})
is(our_wc.Debug, false, "debug off")
is(our_wc.ProcessExistingFiles, false, "process existing off")
is(our_wc.ReportErrors, true, "Error reportin on by default")
is(our_wc.ReportActions, false, "Action reporting on by default")
if our_wc.Paranoia != watch.NoParanoia {
t.Fatal("unexpected paranoia")
}
}
{
app := cli.NewApp()
var our_wc watch.Config
app.Flags = global_flags(&our_wc)
is := make_is(t)
app.Run([]string{"", "--archive=FISHBOWL", "--error-dir=CATBASKET", "--debug", "--log-actions", "--log-errors=false", "--process-existing"})
is(our_wc.ArchiveDir, "FISHBOWL", "archive dir")
is(our_wc.ErrorDir, "CATBASKET", "error dir")
is(our_wc.Debug, true, "debug on")
is(our_wc.ReportActions, true, "action reporting on")
is(our_wc.ReportErrors, false, "error reporting off")
is(our_wc.ProcessExistingFiles, true, "process existing on")
}
}
示例2: Run
func (cmd *Command) Run(args []string) error {
url, args, err := findVulcanUrl(args)
if err != nil {
return err
}
cmd.vulcanUrl = url
cmd.client = api.NewClient(cmd.vulcanUrl, cmd.registry)
app := cli.NewApp()
app.Name = "vctl"
app.Usage = "Command line interface to a running vulcan instance"
app.Flags = flags()
app.Commands = []cli.Command{
NewLogCommand(cmd),
NewKeyCommand(cmd),
NewTopCommand(cmd),
NewHostCommand(cmd),
NewBackendCommand(cmd),
NewFrontendCommand(cmd),
NewServerCommand(cmd),
NewListenerCommand(cmd),
}
app.Commands = append(app.Commands, NewMiddlewareCommands(cmd)...)
return app.Run(args)
}
示例3: main
func main() {
factory := &dockerApp.ProjectFactory{}
app := cli.NewApp()
app.Name = "libcompose-cli"
app.Usage = "Command line interface for libcompose."
app.Version = version.VERSION + " (" + version.GITCOMMIT + ")"
app.Author = "Docker Compose Contributors"
app.Email = "https://github.com/docker/libcompose"
app.Before = cliApp.BeforeApp
app.Flags = append(command.CommonFlags(), dockerApp.DockerClientFlags()...)
app.Commands = []cli.Command{
command.BuildCommand(factory),
command.CreateCommand(factory),
command.DownCommand(factory),
command.KillCommand(factory),
command.LogsCommand(factory),
command.PauseCommand(factory),
command.PortCommand(factory),
command.PsCommand(factory),
command.PullCommand(factory),
command.RestartCommand(factory),
command.RmCommand(factory),
command.RunCommand(factory),
command.ScaleCommand(factory),
command.StartCommand(factory),
command.StopCommand(factory),
command.UnpauseCommand(factory),
command.UpCommand(factory),
}
app.Run(os.Args)
}
示例4: main
func main() {
app := cli.NewApp()
app.Name = "speedland-agent"
app.Usage = "A agent command for speedland.net"
app.Version = "1.0.0"
app.Flags = []cli.Flag{
cli.StringFlag{
"config, c",
"wcg.ini",
"configuration file",
"WCG_INI_FILE",
},
}
app.Before = func(c *cli.Context) error {
wcg.ConfigureProcess(c.String("config"))
// normalize path
lib.Config.Endpoint.Path = ""
wcg.NewLogger(nil).Info("Used configurn file: %q", c.String("config"))
wcg.NewLogger(nil).Info("Target Endpoint: %q", lib.Config.Endpoint)
wcg.NewLogger(nil).Debug("Token: %q", lib.Config.Token)
return nil
}
app.Commands = commands.AllCommands()
app.Run(os.Args)
wcg.WaitLogs()
}
示例5: main
func main() {
//p, _ := os.Create("twobit.cpuprofile")
//pprof.StartCPUProfile(p)
//defer pprof.StopCPUProfile()
app := cli.NewApp()
app.Name = "twobit"
app.Authors = []cli.Author{cli.Author{Name: "Andrew E. Bruno", Email: "[email protected]"}}
app.Usage = "Read/Write .2bit files"
app.Version = "0.0.1"
app.Commands = []cli.Command{
{
Name: "convert",
Usage: "Convert FASTA file to .2bit format.",
Flags: []cli.Flag{
&cli.BoolFlag{Name: "to-fasta, f", Usage: "Convert .2bit file to FASTA"},
&cli.StringFlag{Name: "in, i", Usage: "Input file"},
&cli.StringFlag{Name: "out, o", Usage: "Output file"},
},
Action: func(c *cli.Context) {
if c.Bool("to-fasta") {
ToFasta(c.String("in"), c.String("out"))
return
}
To2bit(c.String("in"), c.String("out"))
},
},
}
app.Run(os.Args)
}
示例6: TestResizeHandleSingle
func TestResizeHandleSingle(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
th.Mux.HandleFunc("/servers/detail", func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Type", "application/json")
fmt.Fprintf(w, `{"servers":[{"ID":"server1","Name":"server1Name"}]}`)
})
app := cli.NewApp()
flagset := flag.NewFlagSet("flags", 1)
flagset.String("id", "", "")
flagset.Set("id", "server1")
c := cli.NewContext(app, flagset, nil)
cmd := &commandResize{
Ctx: &handler.Context{
CLIContext: c,
ServiceClient: client.ServiceClient(),
},
}
expected := &handler.Resource{
Params: ¶msResize{
serverID: "server1",
},
}
actual := &handler.Resource{
Params: ¶msResize{},
}
err := cmd.HandleSingle(actual)
th.AssertNoErr(t, err)
th.AssertEquals(t, expected.Params.(*paramsResize).serverID, actual.Params.(*paramsResize).serverID)
}
示例7: main
func main() {
log := logrus.New()
cli.VersionPrinter = func(c *cli.Context) {
fmt.Printf("%s v=%s d=%s\n", c.App.Name, c.App.Version, GeneratedString)
}
app := cli.NewApp()
app.Name = "artifacts-service"
app.Version = VersionString
app.Commands = []cli.Command{
{
Name: "serve",
ShortName: "s",
Usage: "run the HTTP thing",
Action: func(_ *cli.Context) {
server.Main(log)
},
},
{
Name: "migrate",
ShortName: "m",
Usage: "run database migrations",
Action: func(_ *cli.Context) {
server.MigratorMain(log)
},
},
}
app.Run(os.Args)
}
示例8: NewApp
func NewApp() *cli.App {
app := cli.NewApp()
app.Name = "flint"
app.Usage = "Check a project for common sources of contributor friction"
app.Version = "0.0.4"
app.Flags = []cli.Flag{
cli.BoolFlag{"skip-readme", "skip check for README", ""},
cli.BoolFlag{"skip-contributing", "skip check for contributing guide", ""},
cli.BoolFlag{"skip-license", "skip check for license", ""},
cli.BoolFlag{"skip-bootstrap", "skip check for bootstrap script", ""},
cli.BoolFlag{"skip-test-script", "skip check for test script", ""},
cli.BoolFlag{"skip-scripts", "skip check for all scripts", ""},
cli.BoolFlag{"no-color", "skip coloring the terminal output", ""},
cli.StringFlag{
Name: "github, g",
Value: "",
Usage: "GitHub repository as owner/repo",
},
cli.StringFlag{
Name: "token, t",
Value: "",
EnvVar: "FLINT_TOKEN",
Usage: "GitHub API access token",
},
}
app.Action = func(c *cli.Context) {
run(c)
}
return app
}
示例9: main
func main() {
app := cli.NewApp()
app.Name = "initUpdater"
app.Usage = "initUpdater is to init user table."
app.Action = func(c *cli.Context) {
/* -- DB -- */
db, err := sql.Open("mysql", "root:@/test_bbs")
if err != nil {
panic(err.Error())
}
defer db.Close()
/* -- SQL -- */
sql_1 := "UPDATE user SET name = 'Paul', modified = NOW() WHERE id = 1;"
data1, _ := db.Exec(sql_1)
sql_2 := "UPDATE user SET name = 'John', modified = NOW() WHERE id = 2;"
data2, _ := db.Exec(sql_2)
println(data1)
println(data2)
println("initUdpater Finished!")
}
app.Run(os.Args)
}
示例10: main
func main() {
app := cli.NewApp()
app.Name = "nbad"
app.Usage = "NSCA Buffering Agent (daemon) - Emulates NSCA interface as local buffer/proxy"
var configFile string
var trace bool
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "config, c",
Value: defaultConfLocation,
Usage: "Location of config file on disk",
Destination: &configFile,
},
cli.BoolFlag{
Name: "trace, t",
EnvVar: "NBAD_TRACE",
Usage: "Turn on trace-logging",
Destination: &trace,
},
}
app.Version = "1.0"
app.Action = func(c *cli.Context) {
// load configuration
InitConfig(configFile, TempLogger("STARTUP"))
Config().TraceLogging = trace
startServer()
}
app.Run(os.Args)
}
示例11: main
func main() {
app := cli.NewApp()
app.Version = ""
app.Usage = "Mount and manage Ceph RBD for containers"
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "debug",
Usage: "Turn on debug logging",
EnvVar: "DEBUG",
},
cli.StringFlag{
Name: "master",
Usage: "Set the volmaster host:port",
EnvVar: "MASTER",
Value: "localhost:8080",
},
cli.StringFlag{
Name: "host-label",
Usage: "Set the internal hostname",
EnvVar: "HOSTLABEL",
Value: host,
},
}
app.Action = run
app.Run(os.Args)
}
示例12: Init
func Init() {
cli.AppHelpTemplate = `
GLOBAL OPTIONS:
{{range .Flags}}{{.}}
{{end}}
`
cli.HelpPrinter = func(writer io.Writer, templ string, data interface{}) {
w := tabwriter.NewWriter(os.Stdout, 0, 8, 1, '\t', 0)
t := template.Must(template.New("help").Parse(templ))
err := t.Execute(w, data)
if err != nil {
panic(err)
}
w.Flush()
os.Exit(2)
}
app := cli.NewApp()
app.HideVersion = true
app.Usage = "a go micro app"
app.Action = func(c *cli.Context) {}
app.Before = Setup
app.Flags = Flags
app.RunAndExitOnError()
}
示例13: TestListHandleFlags
func TestListHandleFlags(t *testing.T) {
app := cli.NewApp()
flagset := flag.NewFlagSet("flags", 1)
flagset.String("image", "", "")
flagset.String("flavor", "", "")
flagset.String("name", "", "")
flagset.String("status", "", "")
flagset.String("marker", "", "")
flagset.Set("image", "13ba-75c0-4483-acf9")
flagset.Set("flavor", "1234-b95f-ac5b-cd23")
flagset.Set("name", "server*")
flagset.Set("status", "AVAILABLE")
flagset.Set("marker", "1fd3-4f9f-44df-1b5c")
c := cli.NewContext(app, flagset, nil)
cmd := &commandList{
Ctx: &handler.Context{
CLIContext: c,
},
}
expected := &handler.Resource{
Params: ¶msList{
opts: &osServers.ListOpts{
Image: "13ba-75c0-4483-acf9",
Flavor: "1234-b95f-ac5b-cd23",
Name: "server*",
Status: "AVAILABLE",
Marker: "1fd3-4f9f-44df-1b5c",
},
},
}
actual := &handler.Resource{}
err := cmd.HandleFlags(actual)
th.AssertNoErr(t, err)
th.AssertDeepEquals(t, *expected.Params.(*paramsList).opts, *actual.Params.(*paramsList).opts)
}
示例14: main
func main() {
// Add a check to see if gitversion is blank from the build process
if gitversion == "" {
gitversion = "unknown"
}
app := cli.NewApp()
app.Name = "snapd"
app.Version = gitversion
app.Usage = "A powerful telemetry framework"
app.Flags = []cli.Flag{
flAPIDisabled,
flAPIPort,
flAPIAddr,
flLogLevel,
flLogPath,
flMaxProcs,
flAutoDiscover,
flNumberOfPLs,
flCache,
flPluginTrust,
flKeyringPaths,
flRestCert,
flConfig,
flRestHTTPS,
flRestKey,
flRestAuth,
}
app.Flags = append(app.Flags, scheduler.Flags...)
app.Flags = append(app.Flags, tribe.Flags...)
app.Action = action
app.Run(os.Args)
}
示例15: main
func main() {
app := cli.NewApp()
app.Name = "seaweed-cli"
app.Usage = "Should I go surfing?"
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "apiKey",
Usage: "Magic Seaweed API key",
EnvVar: "MAGIC_SEAWEED_API_KEY",
},
}
app.Commands = []cli.Command{
{
Name: "forecast",
Usage: "forcast <spotId>",
Description: "View the forecast for a spot",
Action: forecast,
},
{
Name: "today",
Usage: "today <spotId>",
Description: "View today's forecast for a spot",
Action: today,
},
{
Name: "tomorrow",
Usage: "tomorrow <spotId>",
Description: "View tomorrow's forecast for a spot",
Action: tomorrow,
},
}
app.Run(os.Args)
}