From cae6bd06e94263a601dff86cf11908265a4f80b4 Mon Sep 17 00:00:00 2001 From: TD-Sky Date: Mon, 4 Sep 2023 20:14:06 +0800 Subject: [PATCH 1/5] feat(dump history): You can specify the time range, regex and format to dump --- Cargo.lock | 61 ++++++++++++++++++--- Cargo.toml | 4 +- src/cli.rs | 58 ++++++++++++++++++++ src/dumper.rs | 56 +++++++++++++++++++ src/history/history.rs | 119 ++++++++++++++++++++++++++++++----------- src/history/mod.rs | 2 +- src/lib.rs | 2 + src/main.rs | 9 ++++ src/settings.rs | 48 ++++++++++++++++- src/shell_history.rs | 16 +++--- src/time.rs | 13 +++++ 11 files changed, 339 insertions(+), 49 deletions(-) create mode 100644 src/dumper.rs create mode 100644 src/time.rs diff --git a/Cargo.lock b/Cargo.lock index f334af96..343e9d33 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -131,6 +131,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "chrono-systemd-time-ng" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2948ae44cb0c28d3d815e2ae4fa6c3bd281f9a07837a880171bbd0486a8f4f41" +dependencies = [ + "chrono", + "maplit", + "once_cell", +] + [[package]] name = "clap" version = "4.3.1" @@ -479,11 +490,18 @@ version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" +[[package]] +name = "maplit" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + [[package]] name = "mcfly" version = "0.8.1" dependencies = [ "chrono", + "chrono-systemd-time-ng", "clap", "crossterm", "csv", @@ -495,6 +513,8 @@ dependencies = [ "regex", "relative-path", "rusqlite", + "serde", + "serde_json", "shellexpand", "unicode-segmentation", ] @@ -528,9 +548,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.2" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "parking_lot" @@ -569,9 +589,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.59" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] @@ -700,9 +720,34 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "serde" -version = "1.0.163" +version = "1.0.188" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" +dependencies = [ + "itoa", + "ryu", + "serde", +] [[package]] name = "shellexpand" @@ -757,9 +802,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "2.0.18" +version = "2.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" +checksum = "0ddc1f908d32ec46858c2d3b3daa00cc35bf4b6841ce4355c7bb3eedf2283a68" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index e9fb324e..f8be31fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,10 @@ debug = true [dependencies] chrono = "0.4" +chrono-systemd-time-ng = "0.2" csv = "1" +serde_json = "1" +serde = { version = "1", features = ["derive"] } humantime = "2.1" directories-next = "2.0" itertools = "0.10" @@ -36,7 +39,6 @@ features = ["functions", "unlock_notify"] version = "0.26" features = ["use-dev-tty"] - [dependencies.clap] version = "4" features = ["derive"] diff --git a/src/cli.rs b/src/cli.rs index 53bfc766..fc39df82 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,4 +1,5 @@ use clap::{Parser, Subcommand, ValueEnum}; +use regex::Regex; use std::path::PathBuf; /// Fly through your shell history @@ -108,6 +109,36 @@ pub enum SubCommand { #[arg(value_enum)] shell: InitMode, }, + + /// Dump history into stdout; the results are sorted by timestamp + Dump { + /// Select all commands ran since the point + #[arg(long)] + since: Option, + + /// Select all commands ran before the point + #[arg(long)] + before: Option, + + /// Sort order [case ignored] + #[arg( + long, + short, + value_name = "ORDER", + value_enum, + default_value_t, + ignore_case = true + )] + sort: SortOrder, + + /// Require commands to match the pattern + #[arg(long, short)] + regex: Option, + + /// The format to dump in + #[arg(long, short, value_enum, default_value_t)] + format: DumpFormat, + }, } #[derive(Clone, Copy, ValueEnum, Default)] @@ -126,8 +157,35 @@ pub enum InitMode { Fish, } +#[derive(Debug, Clone, Copy, ValueEnum, Default)] +#[value(rename_all = "UPPER")] +pub enum SortOrder { + #[default] + #[value(alias = "asc")] + Asc, + #[value(alias = "desc")] + Desc, +} + +#[derive(Debug, Clone, Copy, ValueEnum, Default)] +pub enum DumpFormat { + #[default] + Json, + Csv, +} + impl Cli { pub fn is_init(&self) -> bool { matches!(self.command, SubCommand::Init { .. }) } } + +impl SortOrder { + #[inline] + pub fn to_str(&self) -> &'static str { + match self { + Self::Asc => "ASC", + Self::Desc => "DESC", + } + } +} diff --git a/src/dumper.rs b/src/dumper.rs new file mode 100644 index 00000000..07de86cf --- /dev/null +++ b/src/dumper.rs @@ -0,0 +1,56 @@ +use std::io::{self, BufWriter, Write}; + +use crate::cli::DumpFormat; +use crate::history::{DumpCommand, History}; +use crate::settings::Settings; +use crate::time::to_datetime; + +#[derive(Debug)] +pub struct Dumper<'a> { + settings: &'a Settings, + history: &'a History, +} + +impl<'a> Dumper<'a> { + #[inline] + pub fn new(settings: &'a Settings, history: &'a History) -> Self { + Self { settings, history } + } + + pub fn dump(&self) { + let mut commands = self + .history + .dump(&self.settings.time_range, &self.settings.sort_order); + if commands.is_empty() { + println!("McFly: No history"); + return; + } + + if let Some(pat) = &self.settings.pattern { + commands.retain(|dc| pat.is_match(&dc.cmd)); + } + + match self.settings.dump_format { + DumpFormat::Json => Self::dump2json(&commands), + DumpFormat::Csv => Self::dump2csv(&commands), + } + .unwrap_or_else(|err| panic!("McFly error: Failed while output history ({err})")); + } +} + +impl<'a> Dumper<'a> { + fn dump2json(commands: &[DumpCommand]) -> io::Result<()> { + let mut stdout = BufWriter::new(io::stdout().lock()); + serde_json::to_writer_pretty(&mut stdout, commands).map_err(io::Error::from)?; + stdout.flush() + } + + fn dump2csv(commands: &[DumpCommand]) -> io::Result<()> { + let mut wtr = csv::Writer::from_writer(io::stdout().lock()); + wtr.write_record(["cmd", "when_run"])?; + for dc in commands { + wtr.write_record([dc.cmd.as_str(), to_datetime(dc.when_run).as_str()])?; + } + wtr.flush() + } +} diff --git a/src/history/history.rs b/src/history/history.rs index 92363cbb..26295712 100644 --- a/src/history/history.rs +++ b/src/history/history.rs @@ -1,20 +1,22 @@ #![allow(clippy::module_inception)] -use crate::shell_history; -use rusqlite::named_params; -use rusqlite::{Connection, MappedRows, Row}; -use std::cmp::Ordering; -use std::io::Write; -use std::path::PathBuf; -use std::{fmt, fs, io}; -//use std::time::Instant; +use crate::cli::SortOrder; use crate::history::{db_extensions, schema}; use crate::network::Network; use crate::path_update_helpers; -use crate::settings::{HistoryFormat, ResultFilter, ResultSort, Settings}; +use crate::settings::{HistoryFormat, ResultFilter, ResultSort, Settings, TimeRange}; +use crate::shell_history; use crate::simplified_command::SimplifiedCommand; +use crate::time::to_datetime; use itertools::Itertools; +use rusqlite::named_params; use rusqlite::types::ToSql; +use rusqlite::{Connection, MappedRows, Row}; +use serde::{Serialize, Serializer}; +use std::cmp::Ordering; +use std::io::Write; +use std::path::PathBuf; use std::time::{Instant, SystemTime, UNIX_EPOCH}; +use std::{fmt, fs, io}; #[derive(Debug, Clone, Default)] pub struct Features { @@ -46,6 +48,13 @@ pub struct Command { pub match_bounds: Vec<(usize, usize)>, } +#[derive(Debug, Clone, Serialize)] +pub struct DumpCommand { + pub cmd: String, + #[serde(serialize_with = "ser_to_datetime")] + pub when_run: i64, +} + impl fmt::Display for Command { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.cmd.fmt(f) @@ -58,6 +67,14 @@ impl From for String { } } +#[inline] +fn ser_to_datetime(when_run: &i64, serializer: S) -> Result +where + S: Serializer, +{ + serializer.serialize_str(&to_datetime(*when_run)) +} + #[derive(Debug)] pub struct History { pub connection: Connection, @@ -631,8 +648,22 @@ impl History { format!("SELECT id, cmd, cmd_tpl, session_id, when_run, exit_code, selected, dir FROM commands WHERE session_id = :session_id ORDER BY {} DESC LIMIT :limit OFFSET :offset", order) }; + let closure: fn(&Row) -> rusqlite::Result = |row| { + Ok(Command { + id: row.get(0)?, + cmd: row.get(1)?, + cmd_tpl: row.get(2)?, + session_id: row.get(3)?, + when_run: row.get(4)?, + exit_code: row.get(5)?, + selected: row.get(6)?, + dir: row.get(7)?, + ..Command::default() + }) + }; + if session_id.is_none() { - self.run_query(&query, &[(":limit", &num), (":offset", &offset)]) + self.run_query(&query, &[(":limit", &num), (":offset", &offset)], closure) } else { self.run_query( &query, @@ -641,34 +672,24 @@ impl History { (":limit", &num), (":offset", &offset), ], + closure, ) } } - fn run_query(&self, query: &str, params: &[(&str, &dyn ToSql)]) -> Vec { + fn run_query(&self, query: &str, params: &[(&str, &dyn ToSql)], f: F) -> Vec + where + F: FnMut(&Row<'_>) -> rusqlite::Result, + { let mut statement = self.connection.prepare(query).unwrap(); - let closure: fn(&Row) -> Result = |row| { - Ok(Command { - id: row.get(0)?, - cmd: row.get(1)?, - cmd_tpl: row.get(2)?, - session_id: row.get(3)?, - when_run: row.get(4)?, - exit_code: row.get(5)?, - selected: row.get(6)?, - dir: row.get(7)?, - ..Command::default() - }) - }; - - let command_iter: MappedRows<_> = statement - .query_map(params, closure) + let rows: MappedRows<_> = statement + .query_map(params, f) .unwrap_or_else(|err| panic!("McFly error: Query Map to work ({})", err)); - let mut vec = Vec::new(); - for command in command_iter.flatten() { - vec.push(command); + let mut vec: Vec = Vec::new(); + for row in rows.flatten() { + vec.push(row); } vec @@ -755,6 +776,44 @@ impl History { } } + pub fn dump(&self, time_range: &TimeRange, order: &SortOrder) -> Vec { + let mut where_clause = String::new(); + // Were there condtions in where clause? + let mut has_conds = false; + let mut params: Vec<(&str, &dyn ToSql)> = Vec::with_capacity(2); + + if !time_range.is_full() { + where_clause.push_str("WHERE"); + + if let Some(since) = &time_range.since { + where_clause.push_str(" :since <= when_run"); + has_conds = true; + params.push((":since", since)); + } + + if let Some(before) = &time_range.before { + if has_conds { + where_clause.push_str(" AND"); + } + + where_clause.push_str(" when_run < :before"); + params.push((":before", before)); + } + } + + let query = format!( + "SELECT cmd, when_run FROM commands {} ORDER BY when_run {}", + where_clause, + order.to_str() + ); + self.run_query(&query, params.as_slice(), |row| { + Ok(DumpCommand { + cmd: row.get(0)?, + when_run: row.get(1)?, + }) + }) + } + fn from_shell_history(history_format: HistoryFormat) -> History { print!( "McFly: Importing shell history for the first time. This may take a minute or two..." diff --git a/src/history/mod.rs b/src/history/mod.rs index 208ddb58..c99e2c0c 100644 --- a/src/history/mod.rs +++ b/src/history/mod.rs @@ -1,4 +1,4 @@ -pub use self::history::{Command, Features, History}; +pub use self::history::{Command, DumpCommand, Features, History}; mod db_extensions; mod history; diff --git a/src/lib.rs b/src/lib.rs index 38002532..1635ae37 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ pub mod cli; pub mod command_input; +pub mod dumper; pub mod fake_typer; pub mod fixed_length_grapheme_string; pub mod history; @@ -12,6 +13,7 @@ pub mod path_update_helpers; pub mod settings; pub mod shell_history; pub mod simplified_command; +pub mod time; pub mod trainer; pub mod training_cache; pub mod training_sample_generator; diff --git a/src/main.rs b/src/main.rs index c687df77..49ec898c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +use mcfly::dumper::Dumper; use mcfly::fake_typer; use mcfly::history::History; use mcfly::init::Init; @@ -94,6 +95,11 @@ fn handle_init(settings: &Settings) { Init::new(&settings.init_mode); } +fn handle_dump(settings: &Settings) { + let history = History::load(settings.history_format); + Dumper::new(settings, &history).dump(); +} + fn main() { let settings = Settings::parse_args(); @@ -113,5 +119,8 @@ fn main() { Mode::Init => { handle_init(&settings); } + Mode::Dump => { + handle_dump(&settings); + } } } diff --git a/src/settings.rs b/src/settings.rs index f902408a..70ddbf85 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -1,7 +1,9 @@ -use crate::cli::{Cli, SubCommand}; +use crate::cli::{Cli, DumpFormat, SortOrder, SubCommand}; use crate::shell_history; +use crate::time::parse_timestamp; use clap::Parser; use directories_next::{ProjectDirs, UserDirs}; +use regex::Regex; use std::env; use std::path::PathBuf; use std::str::FromStr; @@ -15,6 +17,7 @@ pub enum Mode { Train, Move, Init, + Dump, } #[derive(Debug)] @@ -66,6 +69,17 @@ pub enum HistoryFormat { Fish, } +/// Time range, it can be: +/// - `..` +/// - `since..before` +/// - `since..` +/// - `..before` +#[derive(Debug, Clone, Default)] +pub struct TimeRange { + pub since: Option, + pub before: Option, +} + #[derive(Debug)] pub struct Settings { pub mode: Mode, @@ -95,6 +109,10 @@ pub struct Settings { pub disable_menu: bool, pub prompt: String, pub disable_run_command: bool, + pub time_range: TimeRange, + pub sort_order: SortOrder, + pub pattern: Option, + pub dump_format: DumpFormat, } impl Default for Settings { @@ -127,6 +145,10 @@ impl Default for Settings { disable_menu: false, prompt: String::from("$"), disable_run_command: false, + time_range: TimeRange::default(), + sort_order: SortOrder::default(), + pattern: None, + dump_format: DumpFormat::default(), } } } @@ -350,6 +372,22 @@ impl Settings { Fish => InitMode::Fish, }; } + + SubCommand::Dump { + since, + before, + sort, + regex, + format, + } => { + settings.mode = Mode::Dump; + + settings.time_range.since = since.as_ref().map(|s| parse_timestamp(s)); + settings.time_range.before = before.as_ref().map(|s| parse_timestamp(s)); + settings.sort_order = sort; + settings.pattern = regex; + settings.dump_format = format; + } } settings.lightmode = is_env_var_truthy("MCFLY_LIGHT"); @@ -426,3 +464,11 @@ fn is_env_var_truthy(name: &str) -> bool { Err(_) => false, } } + +impl TimeRange { + /// Determine the range is full (`..`) + #[inline] + pub fn is_full(&self) -> bool { + self.since.is_none() && self.before.is_none() + } +} diff --git a/src/shell_history.rs b/src/shell_history.rs index 8fc83042..a3e4368b 100644 --- a/src/shell_history.rs +++ b/src/shell_history.rs @@ -267,13 +267,13 @@ mod tests { #[test] fn has_leading_timestamp_works() { - assert_eq!(false, has_leading_timestamp("abc")); - assert_eq!(false, has_leading_timestamp("#abc")); - assert_eq!(false, has_leading_timestamp("#123456")); - assert_eq!(true, has_leading_timestamp("#1234567890")); - assert_eq!(false, has_leading_timestamp("#123456789")); - assert_eq!(false, has_leading_timestamp("# 1234567890")); - assert_eq!(false, has_leading_timestamp("1234567890")); - assert_eq!(false, has_leading_timestamp("hello 1234567890")); + assert!(!has_leading_timestamp("abc")); + assert!(!has_leading_timestamp("#abc")); + assert!(!has_leading_timestamp("#123456")); + assert!(has_leading_timestamp("#1234567890")); + assert!(!has_leading_timestamp("#123456789")); + assert!(!has_leading_timestamp("# 1234567890")); + assert!(!has_leading_timestamp("1234567890")); + assert!(!has_leading_timestamp("hello 1234567890")); } } diff --git a/src/time.rs b/src/time.rs new file mode 100644 index 00000000..47423c56 --- /dev/null +++ b/src/time.rs @@ -0,0 +1,13 @@ +use chrono::{Local, NaiveDateTime, TimeZone}; + +pub fn parse_timestamp(s: &str) -> i64 { + chrono_systemd_time::parse_timestamp_tz(s, Local) + .unwrap_or_else(|err| panic!("McFly error: Failed to parse timestamp ({err})")) + .timestamp() +} + +#[inline] +pub fn to_datetime(timestamp: i64) -> String { + let utc = NaiveDateTime::from_timestamp_opt(timestamp, 0).unwrap(); + Local.from_utc_datetime(&utc).to_rfc3339() +} From 10d2f1e53dd0577558641471c9559319ebb4c166 Mon Sep 17 00:00:00 2001 From: TD-Sky Date: Tue, 12 Sep 2023 13:20:24 +0800 Subject: [PATCH 2/5] doc(readme): mcfly dump --- README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/README.md b/README.md index 773384a8..ecd77527 100644 --- a/README.md +++ b/README.md @@ -206,6 +206,41 @@ To avoid McFly's UI messing up your scrollback history in iTerm2, make sure this iterm2 UI instructions +## Dump history + +McFly can dump the command history into *stdout*. + +For example: +```bash +mcfly dump --since '2023-01-01' --before '2023-09-12 09:15:30' +``` + +It will dump the commands run between *2023-01-01 00:00:00.0* to *2023-09-12 09:15:30*(**exclusive**) as **json**. +You can specify **csv** as dump format via `--format csv` as well. + +Each item in dumped commands has the following fields: +* `cmd`: The run command. +* `when_run`: The time when the command ran in your local timezone. + +You can dump all the commands history without any arguments: +```bash +mcfly dump +``` + +### Timestamp format + +McFly use [chrono-systemd-time-ng] parsing timestamp. + +**chrono-systemd-time-ng** is a non-strict implementation of [systemd.time](https://www.freedesktop.org/software/systemd/man/systemd.time.html), with the following exceptions: +* time units **must** accompany all time span values. +* time zone suffixes are **not** supported. +* weekday prefixes are **not** supported. + +**Users of McFly simply need to understand specifying timezone in timestamp isn't allowed**. +For more details, please refer to [the document of chrono-systemd-time-ng][chrono-systemd-time-ng]. + +[chrono-systemd-time-ng]: https://docs.rs/chrono-systemd-time-ng/latest/chrono_systemd_time/ + ## Settings A number of settings can be set via environment variables. To set a setting you should add the following snippets to your `~/.bashrc` / `~/.zshrc` / `~/.config/fish/config.fish`. From b544416d9926c283235c59416c5dc3f6489ec630 Mon Sep 17 00:00:00 2001 From: TD-Sky Date: Wed, 13 Sep 2023 23:51:47 +0800 Subject: [PATCH 3/5] add `Regex` section --- README.md | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ecd77527..1bd56fcb 100644 --- a/README.md +++ b/README.md @@ -214,8 +214,7 @@ For example: ```bash mcfly dump --since '2023-01-01' --before '2023-09-12 09:15:30' ``` - -It will dump the commands run between *2023-01-01 00:00:00.0* to *2023-09-12 09:15:30*(**exclusive**) as **json**. +will dump the command run between *2023-01-01 00:00:00.0* to *2023-09-12 09:15:30*(**exclusive**) as **json**. You can specify **csv** as dump format via `--format csv` as well. Each item in dumped commands has the following fields: @@ -228,7 +227,6 @@ mcfly dump ``` ### Timestamp format - McFly use [chrono-systemd-time-ng] parsing timestamp. **chrono-systemd-time-ng** is a non-strict implementation of [systemd.time](https://www.freedesktop.org/software/systemd/man/systemd.time.html), with the following exceptions: @@ -236,11 +234,31 @@ McFly use [chrono-systemd-time-ng] parsing timestamp. * time zone suffixes are **not** supported. * weekday prefixes are **not** supported. -**Users of McFly simply need to understand specifying timezone in timestamp isn't allowed**. +Users of McFly simply need to understand **specifying timezone in timestamp isn't allowed**. +McFly will always use your **local timezone**. + For more details, please refer to [the document of chrono-systemd-time-ng][chrono-systemd-time-ng]. [chrono-systemd-time-ng]: https://docs.rs/chrono-systemd-time-ng/latest/chrono_systemd_time/ +### Regex +*Dump* supports filtering commands with regex. +The regex syntax follows [crate regex](https://docs.rs/regex/latest/regex/#syntax). + +For example: +```bash +mcfly dump -r '^cargo run' +``` +will dump all command prefixes with `cargo run`. + +You can use `-r/--regex` and time options at the same time. + +For example: +```bash +mcfly dump -r '^cargo run' --since '2023-09-12 09:15:30' +``` +will dump all command prefixes with `cargo run` ran since *2023-09-12 09:15:30*. + ## Settings A number of settings can be set via environment variables. To set a setting you should add the following snippets to your `~/.bashrc` / `~/.zshrc` / `~/.config/fish/config.fish`. From 23fee4219ba5d1c7dfe45a1f536eb5ec2d9797e6 Mon Sep 17 00:00:00 2001 From: TD-Sky Date: Thu, 16 Nov 2023 20:11:43 +0800 Subject: [PATCH 4/5] fix(chrono): don't use the depreciated API --- Cargo.lock | 510 +++++++++++++++++++++------------------------------- Cargo.toml | 2 +- src/time.rs | 1 + 3 files changed, 205 insertions(+), 308 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 343e9d33..2a633d0a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,24 +4,31 @@ version = 3 [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ "cfg-if", "once_cell", "version_check", + "zerocopy", ] [[package]] name = "aho-corasick" -version = "1.0.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + [[package]] name = "android-tzdata" version = "0.1.1" @@ -39,30 +46,29 @@ dependencies = [ [[package]] name = "anstream" -version = "0.3.2" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", - "is-terminal", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.0" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" +checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" [[package]] name = "anstyle-parse" -version = "0.2.0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" +checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" dependencies = [ "utf8parse", ] @@ -73,17 +79,17 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" dependencies = [ - "windows-sys 0.48.0", + "windows-sys", ] [[package]] name = "anstyle-wincon" -version = "1.0.1" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" dependencies = [ "anstyle", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -98,17 +104,26 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" + [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "cc" -version = "1.0.79" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] [[package]] name = "cfg-if" @@ -118,59 +133,55 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", - "time", "wasm-bindgen", - "winapi", + "windows-targets", ] [[package]] name = "chrono-systemd-time-ng" -version = "0.2.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2948ae44cb0c28d3d815e2ae4fa6c3bd281f9a07837a880171bbd0486a8f4f41" +checksum = "7cd5f2d9ff06c270311aeb9237e2cda17034ce8219f520069dda169d97a3a55c" dependencies = [ "chrono", - "maplit", "once_cell", ] [[package]] name = "clap" -version = "4.3.1" +version = "4.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ed2379f8603fa2b7509891660e802b88c70a79a6427a70abb5968054de2c28" +checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64" dependencies = [ "clap_builder", "clap_derive", - "once_cell", ] [[package]] name = "clap_builder" -version = "4.3.1" +version = "4.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72394f3339a76daf211e57d4bcb374410f3965dcc606dd0e03738c7888766980" +checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc" dependencies = [ "anstream", "anstyle", - "bitflags", "clap_lex", "strsim", ] [[package]] name = "clap_derive" -version = "4.3.1" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59e9ef9a08ee1c0e1f2e162121665ac45ac3783b0f897db7244ae75ad9a8f65b" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" dependencies = [ "heck", "proc-macro2", @@ -180,9 +191,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "colorchoice" @@ -202,7 +213,7 @@ version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a84cda67535339806297f1b331d6dd6320470d2a0fe65381e79ee9e156dd3d13" dependencies = [ - "bitflags", + "bitflags 1.3.2", "crossterm_winapi", "filedescriptor", "libc", @@ -215,18 +226,18 @@ dependencies = [ [[package]] name = "crossterm_winapi" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ae1b35a484aa10e07fe0638d02301c5ad24de82d310ccbd2f3693da5f09bf1c" +checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" dependencies = [ "winapi", ] [[package]] name = "csv" -version = "1.2.2" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "626ae34994d3d8d668f4269922248239db4ae42d538b14c398b74a52208e8086" +checksum = "ac574ff4d437a7b5ad237ef331c17ccca63c46479e5b5453eb8e10bb99a759fe" dependencies = [ "csv-core", "itoa", @@ -236,9 +247,9 @@ dependencies = [ [[package]] name = "csv-core" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" +checksum = "5efa2b3d7902f4b634a20cae3c9c4e6209dc4779feb6863329607560143efa70" dependencies = [ "memchr", ] @@ -286,30 +297,9 @@ dependencies = [ [[package]] name = "either" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" - -[[package]] -name = "errno" -version = "0.3.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "fallible-iterator" @@ -336,29 +326,30 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", ] [[package]] name = "hashbrown" -version = "0.13.2" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" dependencies = [ "ahash", + "allocator-api2", ] [[package]] name = "hashlink" -version = "0.8.2" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0761a1b9491c4f2e3d66aa0f62d0fba0af9a0e2852e4d48ea506632a4b56e6aa" +checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" dependencies = [ "hashbrown", ] @@ -369,12 +360,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" -[[package]] -name = "hermit-abi" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" - [[package]] name = "humantime" version = "2.1.0" @@ -383,16 +368,16 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "iana-time-zone" -version = "0.1.56" +version = "0.1.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows", + "windows-core", ] [[package]] @@ -404,29 +389,6 @@ dependencies = [ "cc", ] -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "is-terminal" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" -dependencies = [ - "hermit-abi", - "io-lifetimes", - "rustix", - "windows-sys 0.48.0", -] - [[package]] name = "itertools" version = "0.10.5" @@ -438,24 +400,35 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "js-sys" -version = "0.3.63" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f37a4a5928311ac501dee68b3c7613a1037d0edb30c8e5427bd832d55d1b790" +checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" dependencies = [ "wasm-bindgen", ] [[package]] name = "libc" -version = "0.2.144" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" + +[[package]] +name = "libredox" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +dependencies = [ + "bitflags 2.4.1", + "libc", + "redox_syscall", +] [[package]] name = "libsqlite3-sys" @@ -468,17 +441,11 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "linux-raw-sys" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" - [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -486,15 +453,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" - -[[package]] -name = "maplit" -version = "1.0.2" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "mcfly" @@ -521,27 +482,27 @@ dependencies = [ [[package]] name = "memchr" -version = "2.5.0" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "mio" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" dependencies = [ "libc", "log", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.48.0", + "wasi", + "windows-sys", ] [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] @@ -564,15 +525,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.7" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-sys 0.45.0", + "windows-targets", ] [[package]] @@ -589,18 +550,18 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.28" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -637,29 +598,41 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.16" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] name = "redox_users" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" dependencies = [ "getrandom", - "redox_syscall", + "libredox", "thiserror", ] [[package]] name = "regex" -version = "1.8.3" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81ca098a9821bd52d6b24fd8b10bd081f47d39c22778cafaa75a2857a62c6390" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", @@ -668,15 +641,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.2" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "relative-path" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bf2521270932c3c7bed1a59151222bd7643c79310f2916f01925e1e16255698" +checksum = "c707298afce11da2efef2f600116fa93ffa7a032b5d7b628aa17711ec81383ca" [[package]] name = "rusqlite" @@ -684,7 +657,7 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01e213bc3ecb39ac32e81e51ebe31fd888a940515173e3a18a35f8c6e896422a" dependencies = [ - "bitflags", + "bitflags 1.3.2", "fallible-iterator", "fallible-streaming-iterator", "hashlink", @@ -692,46 +665,32 @@ dependencies = [ "smallvec", ] -[[package]] -name = "rustix" -version = "0.37.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" -dependencies = [ - "bitflags", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys", - "windows-sys 0.48.0", -] - [[package]] name = "ryu" -version = "1.0.13" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.188" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.188" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" dependencies = [ "proc-macro2", "quote", @@ -740,9 +699,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.105" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "itoa", "ryu", @@ -760,9 +719,9 @@ dependencies = [ [[package]] name = "signal-hook" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "732768f1176d21d09e076c23a93123d40bba92d50c4058da34d45c8de8e682b9" +checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" dependencies = [ "libc", "signal-hook-registry", @@ -790,9 +749,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "strsim" @@ -802,9 +761,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "2.0.30" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ddc1f908d32ec46858c2d3b3daa00cc35bf4b6841ce4355c7bb3eedf2283a68" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", @@ -813,40 +772,29 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.40" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", "syn", ] -[[package]] -name = "time" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", -] - [[package]] name = "unicode-ident" -version = "1.0.9" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-segmentation" @@ -872,12 +820,6 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -886,9 +828,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.86" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73" +checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -896,9 +838,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.86" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb" +checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" dependencies = [ "bumpalo", "log", @@ -911,9 +853,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.86" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258" +checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -921,9 +863,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.86" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" +checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" dependencies = [ "proc-macro2", "quote", @@ -934,9 +876,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.86" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93" +checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" [[package]] name = "winapi" @@ -961,21 +903,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "windows" -version = "0.48.0" +name = "windows-core" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" dependencies = [ - "windows-targets 0.48.0", -] - -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", + "windows-targets", ] [[package]] @@ -984,119 +917,82 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.0", + "windows-targets", ] [[package]] name = "windows-targets" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - -[[package]] -name = "windows-targets" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" -dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_i686_gnu" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_x86_64_gnu" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.0" +name = "windows_x86_64_msvc" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" +name = "zerocopy" +version = "0.7.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +checksum = "e97e415490559a91254a2979b4829267a57d2fcd741a98eee8b722fb57289aa0" +dependencies = [ + "zerocopy-derive", +] [[package]] -name = "windows_x86_64_msvc" -version = "0.48.0" +name = "zerocopy-derive" +version = "0.7.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml index f8be31fd..6b19858d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ debug = true [dependencies] chrono = "0.4" -chrono-systemd-time-ng = "0.2" +chrono-systemd-time-ng = "0.3" csv = "1" serde_json = "1" serde = { version = "1", features = ["derive"] } diff --git a/src/time.rs b/src/time.rs index 47423c56..774d0370 100644 --- a/src/time.rs +++ b/src/time.rs @@ -3,6 +3,7 @@ use chrono::{Local, NaiveDateTime, TimeZone}; pub fn parse_timestamp(s: &str) -> i64 { chrono_systemd_time::parse_timestamp_tz(s, Local) .unwrap_or_else(|err| panic!("McFly error: Failed to parse timestamp ({err})")) + .latest() .timestamp() } From aeae7a02310308d507a648f75e88c9762f216e70 Mon Sep 17 00:00:00 2001 From: TD-Sky Date: Sat, 2 Dec 2023 01:19:51 +0800 Subject: [PATCH 5/5] chore(dep): use `chrono-systemd-time` instead of its fork --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2a633d0a..b5d11538 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -146,10 +146,10 @@ dependencies = [ ] [[package]] -name = "chrono-systemd-time-ng" -version = "0.3.1" +name = "chrono-systemd-time" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cd5f2d9ff06c270311aeb9237e2cda17034ce8219f520069dda169d97a3a55c" +checksum = "429fae93a2fb86c5028aa38bd4a7c0c47b51eb1e30ce059c96dea25bd570dd6c" dependencies = [ "chrono", "once_cell", @@ -462,7 +462,7 @@ name = "mcfly" version = "0.8.1" dependencies = [ "chrono", - "chrono-systemd-time-ng", + "chrono-systemd-time", "clap", "crossterm", "csv", diff --git a/Cargo.toml b/Cargo.toml index 6b19858d..bebd6c74 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ debug = true [dependencies] chrono = "0.4" -chrono-systemd-time-ng = "0.3" +chrono-systemd-time = "0.3" csv = "1" serde_json = "1" serde = { version = "1", features = ["derive"] }