diff --git a/pin/pin.go b/pin/pin.go index f7a512e..5cbcda8 100644 --- a/pin/pin.go +++ b/pin/pin.go @@ -17,7 +17,7 @@ var ( Tool = mtool.T("pin").Func(Run).Desc( "print all the possible PIN combinations made of custom characters", ).Usage( - "", + "", ) ) @@ -68,13 +68,25 @@ func Run(flags *mtool.Flags) { length int rFlag bool ) + var ( + chrsString string + chrs []rune + ) + + flags.StringVar( + &chrsString, + "c", + "0123456789", + "character set for substitution", + "COMBO_CHARS", + ) flags.IntVar( - &lval, "min", 0, + &lval, "min", 1, "min length of the output pins", ) flags.BoolVar( &Lflag, "m", false, - "set the '-min' flag value to 1 (overrides it)", + "set the '-min' flag value to 1 (overrides the '-min' it)", ) flags.IntVar( &length, "max", 0, @@ -84,17 +96,17 @@ func Run(flags *mtool.Flags) { 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() + _ = flags.Parse() - if len(args) == 0 { + /*if len(args) == 0 { flags.Usage() os.Exit(1) - } + }*/ - chrs = []rune(args[0]) + chrs = []rune(chrsString) if length == 0 { - length = len(chrs) + length = 4 } if Lflag { diff --git a/tmpl/tmpl.go b/tmpl/tmpl.go index b9e76e4..6021136 100644 --- a/tmpl/tmpl.go +++ b/tmpl/tmpl.go @@ -8,27 +8,49 @@ import ( "surdeus.su/core/cli/mtool" ) -var( +var ( delim rune Tool = mtool.T("tmpl").Func(Run).Desc( "substitute the inputted runes with the specified words", ).Usage( - "[n_utf8_chars] [n_strings]", + "[n_strings]", ) ) func Run(flags *mtool.Flags) { + + var ( + chrsString string + chrs []rune + skip bool + ) + + flags.StringVar( + &chrsString, + "c", + "0123456789", + "character set for substitution", + "COMBO_CHARS", + ) + + flags.BoolVar( + &skip, + "skip", + false, + "skip and do not substitute not fitting chars", + ) + delim = '\n' args := flags.Parse() - if len(args)<2 || len(args[0]) != len(args)-1 { + /*if len(args)<2 || len(args[0]) != len(args)-1 { flags.Usage() os.Exit(1) - } + }*/ - chrs := []rune(args[0]) - args = args[1:] + chrs = []rune(chrsString) + //args = args[1:] tmpl := make(map[rune] string) for i, s := range args { @@ -44,7 +66,7 @@ func Run(flags *mtool.Flags) { s = s[:len(s)-1] for _, c := range s { s, ok := tmpl[c] - if !ok { + if !skip && !ok { s = string(c) } fmt.Printf("%s", s)