예제 #1
0
파일: main.go 프로젝트: AlexsJones/crashmat
// Generates a 32 character random signature
func main() {
	commander.Go(func() {

		commander.Map(commander.DefaultCommand, "", "",
			func(args objx.Map) {
				fmt.Println(signature.RandomKey(32))
			})

		commander.Map("len length=(int)", "Key length",
			"Specify the length of the generated key",
			func(args objx.Map) {
				length := args.Get("length").Int()
				fmt.Println(signature.RandomKey(length))
			})

	})
}
예제 #2
0
파일: gorc.go 프로젝트: stretchr/gorc
func main() {

	var config = readConfig()
	exclusions = config[configKeyExclusions].([]string)

	commander.Go(func() {
		commander.Map(commander.DefaultCommand, "", "",
			func(args objx.Map) {
				name := ""
				if _, ok := args["name"]; ok {
					name = args["name"].(string)
				}

				if installTests(name) {
					runTests(name)
				} else {
					fmt.Printf("Test dependency installation failed. Aborting test run.\n\n")
				}
			})

		commander.Map("test [name=(string)]", "Runs tests, or named test",
			"If no name argument is specified, runs all tests recursively. If a name argument is specified, runs just that test, unless the argument is \"all\", in which case it runs all tests, including those in the exclusion list.",
			func(args objx.Map) {
				name := ""
				if _, ok := args["name"]; ok {
					name = args["name"].(string)
				}

				if installTests(name) {
					runTests(name)
				} else {
					fmt.Println("Test dependency installation failed. Aborting test run.")
				}
			})

		commander.Map("install [name=(string)]", "Installs tests, or named test",
			"If no name argument is specified, installs all tests recursively. If a name argument is specified, installs just that test, unless the argument is \"all\", in which case it installs all tests, including those in the exclusion list.",
			func(args objx.Map) {
				name := ""
				if _, ok := args["name"]; ok {
					name = args["name"].(string)
				}
				installTests(name)
			})

		commander.Map("vet [name=(string)]", "Vets packages, or named package",
			"If no name argument is specified, vets all packages recursively. If a name argument is specified, vets just that package, unless the argument is \"all\", in which case it vets all packages, including those in the exclusion list.",
			func(args objx.Map) {
				name := ""
				if _, ok := args["name"]; ok {
					name = args["name"].(string)
				}
				vetPackages(name)
			})

		commander.Map("race [name=(string)]", "Runs race detector on tests, or named test",
			"If no name argument is specified, race tests all tests recursively. If a name argument is specified, vets just that test, unless the argument is \"all\", in which case it vets all tests, including those in the exclusion list.",
			func(args objx.Map) {
				name := ""
				if _, ok := args["name"]; ok {
					name = args["name"].(string)
				}
				raceTests(name)
			})

		commander.Map("exclude name=(string)", "Excludes the named directory from recursion",
			"An excluded directory will be skipped when walking the directory tree. Any subdirectories of the excluded directory will also be skipped.",
			func(args objx.Map) {
				exclude(args["name"].(string), config)
				fmt.Printf("\nExcluded \"%s\" from being examined during recursion.\n", args["name"].(string))
				config = readConfig()
				exclusions = config[configKeyExclusions].([]string)
				fmt.Printf("\n%s\n\n", formatExclusionsForPrint(exclusions))
			})

		commander.Map("include name=(string)", "Removes the named directory from the exclusion list", "",
			func(args objx.Map) {
				include(args["name"].(string), config)
				fmt.Printf("\nRemoved \"%s\" from the exclusion list.\n", args["name"].(string))
				fmt.Printf("\n%s\n\n", formatExclusionsForPrint(exclusions))
			})

		commander.Map("exclusions", "Prints the exclusion list", "",
			func(args objx.Map) {
				fmt.Printf("\n%s\n\n", formatExclusionsForPrint(exclusions))
			})
	})

}