示例#1
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
}
示例#2
0
文件: init.go 项目: disorganizer/brig
func initIntoGlobal(folder string, cfg *yamlConfig.Config) error {
	globalRepo, err := global.New()
	if err != nil {
		return err
	}

	ipfsSwarmPort, err := globalRepo.NextIPFSSwarmPort()
	if err != nil {
		return err
	}

	daemonPort, err := globalRepo.NextDaemonPort()
	if err != nil {
		return err
	}

	cfg.Set("ipfs.swarmport", ipfsSwarmPort)
	cfg.Set("daemon.port", daemonPort)

	log.Debugf(
		"Using ports: %d (ipfs-swarm) %d (brigd)",
		ipfsSwarmPort, daemonPort,
	)

	err = globalRepo.AddRepo(global.RepoListEntry{
		RepoPath:      folder,
		DaemonPort:    daemonPort,
		IpfsSwarmPort: ipfsSwarmPort,
	})

	if err != nil {
		return err
	}

	return nil
}