Exemple #1
0
func init() {
	// default logging
	log.SetPrefix("\033[2m[DRONE] ")
	log.SetSuffix("\033[0m\n")
	log.SetOutput(os.Stdout)
	log.SetPriority(log.LOG_NOTICE)
}
Exemple #2
0
func main() {
	// Parse the input parameters
	flag.Usage = usage
	flag.Parse()

	if *help {
		flag.Usage()
		os.Exit(0)
	}

	if *verbose {
		log.SetPriority(log.LOG_DEBUG)
	}

	// Must speicify a command
	args := flag.Args()
	if len(args) == 0 {
		flag.Usage()
		os.Exit(0)
	}

	switch {
	// run drone build assuming the current
	// working directory contains the drone.yml
	case args[0] == "build" && len(args) == 1:
		path, _ := os.Getwd()
		path = filepath.Join(path, ".drone.yml")
		run(path)

	// run drone build where the path to the
	// source directory is provided
	case args[0] == "build" && len(args) == 2:
		path := args[1]
		path = filepath.Clean(path)
		path, _ = filepath.Abs(path)
		path = filepath.Join(path, ".drone.yml")
		run(path)

	// run drone vet where the path to the
	// source directory is provided
	case args[0] == "vet" && len(args) == 2:
		path := args[1]
		path = filepath.Clean(path)
		path, _ = filepath.Abs(path)
		path = filepath.Join(path, ".drone.yml")
		vet(path)

	// run drone vet assuming the current
	// working directory contains the drone.yml
	case args[0] == "vet" && len(args) == 1:
		path, _ := os.Getwd()
		path = filepath.Join(path, ".drone.yml")
		vet(path)

	// print the help message
	case args[0] == "help" && len(args) == 1:
		flag.Usage()
	}

	os.Exit(0)
}