Ejemplo n.º 1
0
//GetCommandsConfig define cli command config
func GetCommandsConfig() []cli.Command {
	return []cli.Command{
		cli.Command{
			Name:  "config",
			Usage: "managment engines",
			Subcommands: []cli.Command{
				cli.Command{
					Name:  "engines",
					Usage: "list known engines",
					Action: func(ctx *cli.Context) {
						logger.Trace.Println("command engines list")
						defer logger.Trace.Println("command engines list done")
						for _, e := range rdb.KnownEngine {
							fmt.Println(e)
						}
					},
				},
				cli.Command{
					Name:  "location",
					Usage: "type location repository",
					Action: func(ctx *cli.Context) {
						logger.Trace.Println("command location")
						fmt.Println("repository:", repofile.GetRepositoryFile(), " default:", repofile.IsDefault())
						defer logger.Trace.Println("command location done")

					},
				},
			}, //subcommands
		},
	}
}
Ejemplo n.º 2
0
Archivo: app.go Proyecto: arteev/dsql
func (a *Application) beforeAction() *Application {
	a.cli.Before = func(ctx *cli.Context) error {
		a.verbose = ctx.GlobalInt("verbose")
		logger.InitToConsole(logger.Level(a.verbose))
		logger.Info.Println("Verbose level:", logger.CurrentLevel)
		if ctx.GlobalIsSet("repo") {
			repofile.SetRepositoryFile(ctx.GlobalString("repo"))
		} else if ctx.GlobalIsSet("r") {
			repofile.SetRepositoryFile(ctx.GlobalString("r"))
		}

		logger.Info.Println("Verbose level:", logger.CurrentLevel)
		logger.Info.Println("Repository location:", repofile.GetRepositoryFile(), "Default:", repofile.IsDefault())
		return nil
	}
	return a
}