Exemple #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
		},
	}
}
Exemple #2
0
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
}