package pin import ( "fmt" //"strconv" //"log" "surdeus.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 ) var ( chrsString string chrs []rune ) flags.StringVar( &chrsString, "c", "0123456789", "character set for substitution", "COMBO_CHARS", ) flags.IntVar( &lval, "min", 1, "min length of the output pins", ) flags.BoolVar( &Lflag, "m", false, "set the '-min' flag value to 1 (overrides the '-min' 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" ) _ = flags.Parse() /*if len(args) == 0 { flags.Usage() os.Exit(1) }*/ chrs = []rune(chrsString) if length == 0 { length = 4 } 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) } }