about summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Taurus/CLI.rakumod29
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);
+};
/* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
void contact_in_group(void **state);
void contact_not_in_group(void **state);
void contact_name_when_name_exists(void **state);
void contact_jid_when_name_not_exists(void **state);
void contact_string_when_name_exists(void **state);
void contact_string_when_name_not_exists(void **state);
void contact_string_when_default_resource(void **state);
void contact_presence_offline(void **state);
void contact_presence_uses_highest_priority(void **state);
void contact_presence_chat_when_same_prioroty(void **state);
void contact_presence_online_when_same_prioroty(void **state);
void contact_presence_away_when_same_prioroty(void **state);
void contact_presence_xa_when_same_prioroty(void **state);
void contact_presence_dnd(void **state);
void contact_subscribed_when_to(void **state);
void contact_subscribed_when_both(void **state);
void contact_not_subscribed_when_from(void **state);
void contact_not_subscribed_when_no_subscription_value(void **state);
void contact_not_available(void **state);
void contact_not_available_when_highest_priority_away(void **state);
void contact_not_available_when_highest_priority_xa(void **state);
void contact_not_available_when_highest_priority_dnd(void **state);
void contact_available_when_highest_priority_online(void **state);
void contact_available_when_highest_priority_chat(void **state);