示例#1
0
// Parse user arguments and modify global variables accordingly.
func setGlobalVars() {

	// Parse commandline arguments.
	//flag.StringVar(&dstArchive, "a", "", "")
	flag.BoolVar(&DoQuiet, "q", false, "")
	flag.Parse()

	// Modify global variables based on commandline arguments.
	Files = os.Args[1:]

	// if !DoQuiet && dstArchive == "" {
	//  return
	// }

	if len(Files) > 1 {
		DoQuiet = true
	}

	if DoQuiet {
		boolArgs := []string{"-q"}
		Files = slices.Filter(Files, boolArgs...)
		print = printNoop
	}

	// if dstArchive != "" {
	//  // doSingleArchive = true
	//  Files = slices.Filter(Files, dstArchive)
	// }
	return
}
示例#2
0
func flags() {

	// fmt.Println("flags()")

	bools := []string{"-b", "-f"}

	flag.BoolVar(&PrintBase, "b", false, "")
	flag.BoolVar(&PrintFull, "f", false, "")
	flag.Parse()

	Paths = os.Args[1:]
	Paths = slices.Filter(Paths, bools...)
}