Ejemplo n.º 1
0
func main() {
	initKingpin()

	config.APIToken = GetAPIToken()
	config.StoriesCachePath = PivotalStoriesCacheFilePath()

	switch kingpin.Parse() {
	case "install":
		gitDir, err := git.GitDir()
		if err != nil {
			log.Fatal("Error while installing:\n", err)
		}
		hooksDir := filepath.Join(gitDir, "hooks")
		if err := os.MkdirAll(hooksDir, 0775); err != nil {
			log.Fatalf("Error while creating hooks directory: %s\n", err)
		}

		InstallHookShims(hooksDir, HOOKS[:])

	case "self-update":
		SelfUpdate()

	case "update-pivotal-stories":
		githooks.UpdatePivotalStories(config)

	case "pre-commit":
		githooks.PreCommit()

	case "prepare-commit-msg":
		config.StoriesCachePath = PivotalStoriesCacheFilePath()

		githooks.PrepareCommitMsg(*messageFilepath, *messageSource, *messageSourceCommit, config)

	case "commit-msg":
		config.StoriesCachePath = PivotalStoriesCacheFilePath()

		githooks.CommitMsg(*messageFilepath, config)
	}
}
Ejemplo n.º 2
0
func main() {
	kingpin.Flag("debug", "Show extra info").BoolVar(&debug)
	kingpin.Command("cleanup-images", "Cleanup any untagged images")
	kingpin.Command("cleanup-containers", "Cleanup any containers based on untagged images")
	command := kingpin.Parse() // get selected command or die here

	createClient()

	// Log events from the Daemon
	var events = make(chan *docker.APIEvents)
	client.AddEventListener(events)
	go logDockerEvents(events)

	switch command {
	case "cleanup-images":
		cleanupImages()
	case "cleanup-containers":
		cleanupContainers()
	}

	// FIXME: Wait a short moment for any last Daemon events to come back
	time.Sleep(time.Second * 1)
}