diff options
author | Andinus <andinus@nand.sh> | 2021-08-15 17:48:21 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2021-08-15 17:48:21 +0530 |
commit | f1a450291a526dcc0d0b19025a55e37be6c4aa77 (patch) | |
tree | f57585a27ccf31ea22265cf69c96f76881ef6291 /lib | |
parent | 8a6b84374a42c4e28f25eaf0979dc4ccc7630549 (diff) | |
download | taurus-f1a450291a526dcc0d0b19025a55e37be6c4aa77.tar.gz |
Add Initial implementation, update README
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Taurus/CLI.rakumod | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/Taurus/CLI.rakumod b/lib/Taurus/CLI.rakumod new file mode 100644 index 0000000..db6be9e --- /dev/null +++ b/lib/Taurus/CLI.rakumod @@ -0,0 +1,29 @@ +use CSV::Parser; +use Terminal::UI; +use Terminal::Spinners; +use Text::Table::Simple; + +#| parses Call Logs +unit sub MAIN ( + Str $log where *.IO.f, #= input log file to parse + UInt :$digits = 10, #= number of significant digits +); + +my @logs; +my Str %contacts{Str}; +Spinner.new(:type<bounce2>).await: Promise.start: { + my $p = CSV::Parser.new(); + # 0: Name, 1: Phone number, 2: Call Type, 3: Timestamp, + # 4: Duration, 5: Sim used. + + # Turn the Hash to an Array. + @logs = @($log.IO.lines.skip.hyper.map({$p.parse($_)})>>.{0..4} + # Discard invalid phone numbers. + .grep(*.[1].chars >= $digits)); + + # Discard non-significant digits from phone numbers. + .[1] = .[1].substr(*-10) for @logs; + + # Build contact list. + %contacts{.[1]} = .[0] for @logs.grep(*.[0].chars > 0); +}; |