package pin import ( "fmt" //"strconv" //"log" "vultras.su/core/cli/mtool" "os" ) var ( Lflag bool lval int delim rune = '\n' nVal int chrs []rune Tool = mtool.T("pin").Func(Run).Desc( "print all the possible PIN combinations made of custom characters", ).Usage( "", ) ) func Pow(x, p int) int { ret := 1 for i:=0 ; i

nVal { return false } } } } return true } func Run(flags *mtool.Flags) { var ( length int rFlag bool ) flags.IntVar( &lval, "min", 0, "min length of the output pins", ) flags.BoolVar( &Lflag, "m", false, "set the '-min' flag value to 1 (overrides it)", ) flags.IntVar( &length, "max", 0, "max length of the output pins", ) flags.IntVar(&nVal, "rep", 1, "max repeats of the rune." ) flags.BoolVar(&rFlag, "R", false, "make the maximum repeat equal to the length of input chars" ) args := flags.Parse() if len(args) == 0 { flags.Usage() os.Exit(1) } chrs = []rune(args[0]) if length == 0 { length = len(chrs) } if Lflag { lval = 1 } if rFlag { nVal = len(chrs) } if lval != 0 { if lval > length { flags.Usage() os.Exit(1) } for i := lval ; i<=length ; i++ { printPins(chrs, i) } } else { printPins(chrs, length) } }