Exemple #1
0
func init() {
	flag.Usage = func() {
		fmt.Printf(`Usage: %s [OPTION]... [FILE]...
Concatenate FILE(s), or standard input, to standard output.

`, flag.Program)
		flag.DBE()
	}
	flag.ProgVersion = "2.0"
	flag.Parse()

	// -vET
	if *all {
		*nonPrint = true
		*npTabs = true
		*npEnds = true
	}
	if *npEnds {
		*ends = true
	}
	if *blank {
		*number = true
	}
	if *npTabs {
		*tabs = true
	}
	if *all || *npEnds || *npTabs || *nonPrint {
		showNonPrinting = true
	}
	if !(*number || *ends || showNonPrinting ||
		*tabs || *squeeze) {
		simple = true
	}
}
func main() {
	flag.Usage = func() {
		fmt.Printf(`Usage: %s [OPTION]...
Print certain system information. With no OPTION, same as -s.

`, flag.Program)
		flag.DBE()
	}
	flag.ProgVersion = "1.1"
	flag.Parse()

	toprint := decodeFlags()
	if toprint == 0 {
		toprint = printKernelName
	}

	if toprint.isSet(
		(printKernelName | printNodeName | printKernelRelease |
			printKernelVersion | printMachine)) {

		name, err := genInfo()
		if err != nil {
			fatal.Fatalln("cannot get system name")
		}

		if toprint.isSet(printKernelName) {
			print(name.sysname)
		}
		if toprint.isSet(printNodeName) {
			print(name.nodename)
		}
		if toprint.isSet(printKernelRelease) {
			print(name.release)
		}
		if toprint.isSet(printKernelVersion) {
			print(name.version)
		}
		if toprint.isSet(printMachine) {
			print(name.machine)
		}
	}

	if toprint.isSet(printProcessor) {
		element := unknown
		if toprint != maxUint || element != unknown {
			print(element)
		}
	}

	if toprint.isSet(printHardwarePlatform) {
		element := unknown
		if toprint != maxUint || hostOS != unknown {
			print(element)
		}
	}

	if toprint.isSet(printOperatingSystem) {
		print(hostOS)
	}

	os.Stdout.WriteString("\n")
}