diff options
Diffstat (limited to 'main.odin')
-rw-r--r-- | main.odin | 25 |
1 files changed, 20 insertions, 5 deletions
@@ -12,6 +12,7 @@ Arg_Type :: enum { FROM, TO, IN, + SUBSTRING, } Arg_Flags :: bit_set[Arg_Type] @@ -41,6 +42,7 @@ main :: proc() { from_filter : Filter in_filter : Filter in_filter_out : Filter + substring : string file_index_buffer : [dynamic]int @@ -58,6 +60,8 @@ main :: proc() { parsing = .FROM case "-i": parsing = .IN + case "-s": + parsing = .SUBSTRING case "-v": verbose = true case "-h": @@ -70,6 +74,7 @@ main :: proc() { fmt.println("\t-t To: Filter up to and NOT including a specific time.") fmt.println("\t-f From: Filter from and including a specific time.") fmt.println("\t-i In: Filter to inside a specific year, month, etc.") + fmt.println("\t-s Substring: Case sensitive filter based on event names.") fmt.println("\t-v Verbose: Prints more info.") fmt.println("\t-h Help: Show this screen.") @@ -100,7 +105,11 @@ main :: proc() { filters |= {.IN} fmt.println("IN filter set up from", momentToString(in_filter.time), "to", momentToString(in_filter_out.time)) parsing = .NONE - + case .SUBSTRING: + substring = arg + fmt.printfln("SUBSTRING filter set to \"{}\"", substring) + filters |= {.SUBSTRING} + parsing = .NONE } } @@ -119,23 +128,29 @@ main :: proc() { if ok { hours : f64 = 0 for each_block in timeblocks { - if verbose do fmt.println("Timeblock:", timeblockToString(each_block)) + if verbose do fmt.println("Block:", timeblockToString(each_block)) pass := true if .FROM in filters { pass_from := greatEq(each_block.start, from_filter.time) - if verbose do if !pass_from do fmt.println(" FILTERED! By From filter") + if verbose do if !pass_from do fmt.println(" └ FILTERED! By From filter.") pass &= pass_from } if .TO in filters { pass_to := lessEq(each_block.start, to_filter.time) - if verbose do if !pass_to do fmt.println(" FILTERED! By To filter") + if verbose do if !pass_to do fmt.println(" └ FILTERED! By To filter.") pass &= pass_to } if .IN in filters { pass_in := lessEq(in_filter.time, each_block.start) && lessEq(each_block.start, in_filter_out.time) - if verbose do if !pass_in do fmt.println(" FILTERED! By In filter: ") + if verbose do if !pass_in do fmt.println(" └ FILTERED! By In filter.") pass &= pass_in } + if .SUBSTRING in filters { + pass_substring := strings.contains(each_block.title, substring) + if verbose do if !pass_substring do fmt.println(" └ FILTERED! By Substring filter.") + pass &= pass_substring + } + //if verbose do fmt.printf("\n") if !pass do continue |