Exemplo n.º 1
0
// guessRepoFolder tries to find the repository path
// by using a number of sources.
func guessRepoFolder() string {
	folder := repo.GuessFolder()
	if folder == "" {
		log.Errorf("This does not like a brig repository (missing .brig)")
		os.Exit(BadArgs)
	}

	return folder
}
Exemplo n.º 2
0
func loadConfig() *config.Config {
	// We do not use guessRepoFolder() here. It might abort
	folder := repo.GuessFolder()
	cfg, err := repoconfig.LoadConfig(filepath.Join(folder, ".brig", "config"))
	if err != nil {
		log.Warningf("Could not load config: %v", err)
		log.Warningf("Falling back on config defaults...")
		return repoconfig.CreateDefaultConfig()
	}

	return cfg
}
Exemplo n.º 3
0
func handleConfigSet(ctx *cli.Context, cfg *config.Config) error {
	key := ctx.Args().First()
	value := ctx.Args().Get(1)
	if err := cfg.Set(key, value); err != nil {
		return ExitCode{
			BadArgs,
			fmt.Sprintf("Could not set %s: %v", key, err),
		}
	}

	folder := repo.GuessFolder()
	if _, err := repoconfig.SaveConfig(filepath.Join(folder, ".brig", "config"), cfg); err != nil {
		return ExitCode{
			UnknownError,
			fmt.Sprintf("Could not save config: %v", err),
		}
	}
	return nil
}