32 lines
479 B
Go
32 lines
479 B
Go
package read
|
|
/* Plan9 read or something to read into variables. */
|
|
import(
|
|
"os"
|
|
"bufio"
|
|
"fmt"
|
|
"surdeus.su/core/cli/mtool"
|
|
)
|
|
|
|
var(
|
|
nLines int
|
|
)
|
|
|
|
func Run(flagSet *mtool.Flags) {
|
|
flagSet.IntVar(&nLines, "n", 1, "amount of lines")
|
|
flagSet.Parse()
|
|
//args := flagSet.Args()
|
|
|
|
if nLines <= 0 {
|
|
flagSet.Usage()
|
|
}
|
|
|
|
rd := bufio.NewReader(os.Stdin)
|
|
for nLines != 0 {
|
|
line, err := rd.ReadString('\n')
|
|
if err != nil {
|
|
os.Exit(0)
|
|
}
|
|
fmt.Print(line)
|
|
nLines -= 1
|
|
}
|
|
}
|