aboutsummaryrefslogtreecommitdiffstats
path: root/src/command
diff options
context:
space:
mode:
authorEllie Huxtable <ellie@elliehuxtable.com>2023-02-14 09:45:55 +0000
committerGitHub <noreply@github.com>2023-02-14 09:45:55 +0000
commit1f7d3a34e76c9ce01a7b0374b9577f9b20314774 (patch)
tree17a2089008f5b51c31542aa8d2bc30e12468ee09 /src/command
parentAdd `history_filter` cfg to exclude commands from history (#515) (#716) (diff)
downloadatuin-1f7d3a34e76c9ce01a7b0374b9577f9b20314774.zip
Check before unwrapping in stats (#717)
Should fix the error @pdecat found!
Diffstat (limited to 'src/command')
-rw-r--r--src/command/client/stats.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/command/client/stats.rs b/src/command/client/stats.rs
index b6634233..45bc3571 100644
--- a/src/command/client/stats.rs
+++ b/src/command/client/stats.rs
@@ -26,9 +26,13 @@ pub struct Cmd {
fn compute_stats(history: &[History], count: usize) -> Result<()> {
let mut commands = HashMap::<&str, usize>::new();
for i in history {
- *commands
- .entry(i.command.split_ascii_whitespace().next().unwrap())
- .or_default() += 1;
+ let command = i.command.split_ascii_whitespace().next();
+
+ if command.is_none() {
+ continue;
+ }
+
+ *commands.entry(command.unwrap()).or_default() += 1;
}
let unique = commands.len();
let mut top = commands.into_iter().collect::<Vec<_>>();