Пример #1
0
func main() {
	flag.Usage = fusage
	flag.Parse()

	args := flag.Args()
	if len(args) < 1 {
		usage(os.Stderr)
		os.Exit(1)
	}

	if args[0] == "help" {
		help(args)
	}

	once.Do(buildUtilMap)

	for _, cmd := range commands {
		if cmd.Name == args[0] {
			cmd.Flag.Usage = func() { cmd.Usage() }
			cmd.Flag.Parse(args[1:])
			args = cmd.Flag.Args()
			cmd.Run(args)
			return
		}
	}

	fmt.Fprintf(os.Stderr, "go-coreutils: unknown command %q\nRun 'go-coreutils help for usage'\n", args[0])
}
Пример #2
0
func main() {
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "%s", help)
		os.Exit(1)
	}
	flag.Parse()

	if *vers {
		fmt.Printf("%s", version)
		return
	}

	if *includeSpecial && *special > -1 {
		exit("Cannot use --include-special/-i and --special/-s at the same time")
	}

	if fix(*special) < 0 ||
		fix(*upper) < 0 ||
		*digits < 0 ||
		*lower < 0 ||
		*length < 0 {
		exit("special, uppercase, digits, and length must be positive integers")
	}

	if *special+*upper+*digits+*lower > *length {
		exit("special + uppercase + digits should be <= length")
	}

	if *exclude != "" {
		for i := range *exclude {
			specialTable.remove((*exclude)[i])
		}
	}

	if *includeSpecial {
		*special = int(next(*length - (*upper + *digits + *lower)))
	}

	if *upper < 0 {
		n := *length - (*special + *digits + *lower)
		if n > 0 {
			*upper = int(next(n))
		}
	}

	fn := randAlg
	if *alg != "" {
		var ok bool
		if fn, ok = knownAlgorithms[strings.ToLower(*alg)]; !ok {
			exit("unknown algorithm %q", *alg)
		}
	}

	for i := *number; i > 0; i-- {
		fmt.Println(fn(*b64))
	}
}
Пример #3
0
func main() {
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "%s", Help)
		os.Exit(1)
	}
	flag.Parse()

	if *version {
		fmt.Printf("%s\n", Version)
		os.Exit(0)
	}

	// 1 if --dereference, 0 if --no-dereference, -1 if neither
	// has been specified.
	// deref := -1
	// bitFlags := 12 // todo
}