Skip to content

Commit

Permalink
(#35) add -with-lc flag
Browse files Browse the repository at this point in the history
Signed-off-by: hahwul <hahwul@gmail.com>
  • Loading branch information
hahwul committed Oct 13, 2021
1 parent b02af6c commit 88e9899
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 41 deletions.
42 changes: 22 additions & 20 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func main() {
reverseOption := flag.Bool("reverse", false, "Reverse string in line")
uniqOption := flag.Bool("uniq", false, "Remove duplicated line")
injectOption := flag.String("inject", "", "Inject stdin into the format of the factor value (This is %%INJECT%% line!)")
withLCOption := flag.Bool("with-lc", false, "With letters count (colorize magenta)")

// Custom usage
flag.Usage = func() {
Expand Down Expand Up @@ -64,26 +65,27 @@ func main() {

// Set Options
options := model.Options{
Files: files,
Append: *appendOption,
ChunkedLine: *chunkedLineOption,
WithLine: *withLineOption,
WithTimestamp: *withTimeOption,
Prefix: *prefixOption,
Suffix: *suffixOption,
RemoveNewLine: *rmnlOption,
Distribute: *distributeOption,
Regex: *regexOption,
RegexV: *regexvOption,
Replace: *replaceOption,
Find: *findOption,
Color: !*colorOption,
Split: *splitOption,
Format: *formatOption,
Debug: *debugOption,
Reverse: *reverseOption,
Uniq: *uniqOption,
Inject: *injectOption,
Files: files,
Append: *appendOption,
ChunkedLine: *chunkedLineOption,
WithLine: *withLineOption,
WithTimestamp: *withTimeOption,
Prefix: *prefixOption,
Suffix: *suffixOption,
RemoveNewLine: *rmnlOption,
Distribute: *distributeOption,
Regex: *regexOption,
RegexV: *regexvOption,
Replace: *replaceOption,
Find: *findOption,
Color: !*colorOption,
Split: *splitOption,
Format: *formatOption,
Debug: *debugOption,
Reverse: *reverseOption,
Uniq: *uniqOption,
Inject: *injectOption,
WithLettersCount: *withLCOption,
}
if *debugOption {
printing.DebugMsg("MSG", "Running on Debug mode", options.Debug)
Expand Down
5 changes: 5 additions & 0 deletions pkg/gee/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ func StringProc(l string, stdLine int, options model.Options) (string, string) {
resultPlain = "[" + GetNowTime() + "] " + resultPlain
}

if options.WithLettersCount {
result = au.BrightMagenta("["+strconv.Itoa(len(l))+"] ").String() + result
resultPlain = "[" + strconv.Itoa(len(l)) + "] " + resultPlain
}

if options.Split != "" {
resultArr = strings.Split(result, options.Split)
resultPlainArr = strings.Split(resultPlain, options.Split)
Expand Down
43 changes: 22 additions & 21 deletions pkg/model/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@ package model

// Options is struct of gee options
type Options struct {
Files []string
Append bool
ChunkedLine int
ChunkedSize string
Prefix string
Suffix string
WithTimestamp bool
WithLine bool
RemoveNewLine bool
Format string
Regex string
RegexV string
Split string
Distribute bool
Replace string
Find string
Color bool
Debug bool
Reverse bool
Uniq bool
Inject string
Files []string
Append bool
ChunkedLine int
ChunkedSize string
Prefix string
Suffix string
WithTimestamp bool
WithLine bool
RemoveNewLine bool
Format string
Regex string
RegexV string
Split string
Distribute bool
Replace string
Find string
Color bool
Debug bool
Reverse bool
Uniq bool
Inject string
WithLettersCount bool
}

0 comments on commit 88e9899

Please sign in to comment.