예제 #1
0
import (
	"fmt"
	"log"
	"os"

	"github.com/EricLagergren/go-coreutils/internal/flag"
)

const (
	unknown = "unknown"
	procCPU = "/proc/cpuinfo"
	maxUint = ^printer(0)
)

var (
	all = flag.BoolP("all", "a", false, `print all information, in the following order,
                             except omit -p and -i if unknown:`)
	kernelName      = flag.BoolP("kernel-name", "s", false, "print the kernel name")
	nodeName        = flag.BoolP("nodename", "n", false, "print the network node hostname")
	release         = flag.BoolP("kernel-release", "r", false, "print the kernel release")
	version         = flag.BoolP("kernel-version", "v", false, "print the kernel version")
	machine         = flag.BoolP("machine", "m", false, "print the machine hardware name")
	processor       = flag.BoolP("processor", "p", false, "print the processor tyoe or \"unknown\"")
	hwPlatform      = flag.BoolP("hardware-platform", "i", false, "print the hardware platform or \"unknown\"")
	operatingSystem = flag.BoolP("operating-system", "o", false, "print the operating system")

	fatal = log.New(os.Stderr, "", 0)
)

type printer uint

// Enumerated printing options.
예제 #2
0
// Use of this source code is governed by the GPL v3 or later.

package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"

	"github.com/EricLagergren/go-coreutils/internal/flag"
)

var (
	all        = flag.BoolP("show-all", "A", false, "equivalent to -vET")
	blank      = flag.BoolP("number-nonblank", "b", false, "number nonempty output lines, overrides -n")
	npEnds     = flag.BoolP("ends", "e", false, "equivalent to -vE")
	ends       = flag.BoolP("show-ends", "E", false, "display $ at end of each line")
	number     = flag.BoolP("number", "n", false, "number all output lines")
	squeeze    = flag.BoolP("squeeze-blank", "s", false, "suppress repeated empty output lines")
	npTabs     = flag.BoolP("tabs", "t", false, "equivalent to -vT")
	tabs       = flag.BoolP("show-tabs", "T", false, "display TAB characters as ^I")
	nonPrint   = flag.BoolP("non-printing", "v", false, "use ^ and M- notation, except for LFD and TAB")
	unbuffered = flag.BoolP("unbuffered", "u", false, "(ignored)")

	totalNewline    int64
	showNonPrinting bool
	simple          bool

	fatal = log.New(os.Stderr, "", 0)
예제 #3
0
	// Our cumulative number of lines, words, chars, and bytes.
	totalLines    int64
	totalWords    int64
	totalChars    int64
	totalBytes    int64
	maxLineLength int64

	// For pretty printing.
	numberWidth int
	printOne    bool

	// For getFileStatus.
	errNoStat = errors.New("no stat")

	// Our cli args
	printLines      = flag.BoolP("lines", "l", false, "print the newline counts")
	printWords      = flag.BoolP("words", "w", false, "print the word counts")
	printChars      = flag.BoolP("chars", "m", false, "print the character counts")
	printBytes      = flag.BoolP("bytes", "c", false, "print the byte counts")
	printLineLength = flag.BoolP("max-line-length", "L", false, "print the length of the longest line")
	filesFrom       = flag.String("files0-from", "", `read input from the files specified by
                             NUL-terminated names in file F;
                             If F is - then read names from standard input`)
	tabWidth     = flag.Int64P("tab", "t", 8, "change the tab width")
	constVersion = flag.BoolP("unicode-version", "u", false, "display unicode version and exit")

	logger = log.New(os.Stderr, "", 0)
)

func fatal(format string, v ...interface{}) {
	logger.Fatalf("%s: %s\n", flag.Program, fmt.Sprintf(format, v...))