yes: "-N" option implemented.

This commit is contained in:
jienfak 2020-05-03 05:59:39 +05:00
parent 97a5d794e1
commit 58bb9ea140

View file

@ -8,10 +8,19 @@ import(
"strings"
"github.com/jienfak/goblin/input"
)
var(
nArg int
)
func yes(s string){
for{
fmt.Print(s)
if nArg<0{
for{
fmt.Print(s)
}
} else {
for i:=0 ; i<nArg ; i+=1 {
fmt.Print(s)
}
}
}
@ -27,6 +36,7 @@ func Run(args []string) int {
flagSet := flag.NewFlagSet(arg0, flag.ExitOnError)
flagSet.BoolVar(&stdinFlag, "s", false, "Read string from stdin.")
flagSet.BoolVar(&nFlag, "n", false, "Do not add net line character.")
flagSet.IntVar(&nArg, "N", -1, "Repeat input N times. Negative value means infinite cycle.")
flagSet.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage of %s: %s [options] [string]\n", arg0, arg0)
flagSet.PrintDefaults()