yes: "-N" option implemented.
This commit is contained in:
parent
97a5d794e1
commit
58bb9ea140
1 changed files with 12 additions and 2 deletions
10
yes/yes.go
10
yes/yes.go
|
@ -8,11 +8,20 @@ import(
|
|||
"strings"
|
||||
"github.com/jienfak/goblin/input"
|
||||
)
|
||||
var(
|
||||
nArg int
|
||||
)
|
||||
|
||||
func yes(s string){
|
||||
if nArg<0{
|
||||
for{
|
||||
fmt.Print(s)
|
||||
}
|
||||
} else {
|
||||
for i:=0 ; i<nArg ; i+=1 {
|
||||
fmt.Print(s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Run(args []string) int {
|
||||
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue