示例#1
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)
}
示例#2
0
func initKingpin() {
	var cmd *kingpin.CmdClause

	kingpin.Version(Version())

	cmd = kingpin.Command("install", "Install scripts at .git/hooks/* for each git-hook provided by this tool")
	cmd.Flag("force", "Don't ask to overwrite target file, always clobber").BoolVar(clobber)
	cmd.Flag("noclobber", "Don't ask to overwrite target file, always skip").BoolVar(noclobber)

	kingpin.Command("self-update", "Check for updates of goodguide-git-hooks and download the newer version if available")

	kingpin.Command("update-pivotal-stories", "Update cache of pivotal stories manually")

	// git hooks commands:
	kingpin.Command("pre-commit", "Verifies the files about to be committed follow certain guidelines regarding e.g. whitespace, syntax, etc.")

	cmd = kingpin.Command("prepare-commit-msg", "Augment the default commit message template with commented-out PivotalTracker Story IDs to make it easy to tag commits")
	cmd.Arg("message_path", "Path to the file which will be sent to the editor and ultimately become the commit log message").
		Required().
		ExistingFileVar(messageFilepath)
	cmd.Arg("source", "Source of the commit message going into this hook").
		EnumVar(&messageSource, "message", "merge", "commit", "squash", "template")
	cmd.Arg("commit_sha", "If source is 'commit', this is the SHA1 of the source commit").
		StringVar(messageSourceCommit)

	cmd = kingpin.Command("commit-msg", "Checks the commit message for PivotalTracker story ID, bad whitespace, syntax, etc.")
	cmd.Arg("message_path", "Path to the file that holds the proposed commit log message").
		Required().
		ExistingFileVar(messageFilepath)

	// no-ops:
	cmd = kingpin.Command("applypatch-msg", "no-op")
	cmd.Arg("args", "").Strings()
	cmd = kingpin.Command("post-update", "no-op")
	cmd.Arg("args", "").Strings()
	cmd = kingpin.Command("pre-applypatch", "no-op")
	cmd.Arg("args", "").Strings()
	cmd = kingpin.Command("pre-push", "no-op")
	cmd.Arg("args", "").Strings()
	cmd = kingpin.Command("pre-rebase", "no-op")
	cmd.Arg("args", "").Strings()
}