Example #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
		},
	}
}
Example #2
0
func (r *DBContextSQLite) init() error {
	var err error
	repofile.PrepareLocation()
	r.dbs, err = sql.Open("sqlite3", repofile.GetRepositoryFile())
	if err != nil {
		return err
	}
	if !r.isExistsMetadata() {
		if err := r.createDataBase(); err != nil {
			return err
		}
	}
	return nil
}
Example #3
0
File: app.go Project: 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
}