aboutsummaryrefslogtreecommitdiffstats
path: root/src/command/client/search.rs
diff options
context:
space:
mode:
authorBaptiste <32563450+BapRx@users.noreply.github.com>2023-01-26 11:57:52 +0100
committerGitHub <noreply@github.com>2023-01-26 10:57:52 +0000
commit893a395f12d29b6b6676db3672fb7e600c49aff7 (patch)
tree2944bc8b07ec3dd44eca75fa411a5dc1d93fa1c6 /src/command/client/search.rs
parentUpdate contributors.rs (diff)
downloadatuin-893a395f12d29b6b6676db3672fb7e600c49aff7.zip
feat(history): Add new flag to allow custom output format (#662)
* feat(history): Add new flag to allow custom output format * more efficient formatting * add user and host * docs Co-authored-by: Conrad Ludgate <conrad.ludgate@truelayer.com>
Diffstat (limited to '')
-rw-r--r--src/command/client/search.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/command/client/search.rs b/src/command/client/search.rs
index e528576d..53471ec1 100644
--- a/src/command/client/search.rs
+++ b/src/command/client/search.rs
@@ -16,7 +16,7 @@ mod duration;
mod event;
mod history_list;
mod interactive;
-pub use duration::format_duration;
+pub use duration::{format_duration, format_duration_into};
#[allow(clippy::struct_excessive_bools)]
#[derive(Parser)]
@@ -74,6 +74,11 @@ pub struct Cmd {
/// Show only the text of the command
#[arg(long)]
cmd_only: bool,
+
+ /// Available variables: {command}, {directory}, {duration}, {user}, {host} and {time}.
+ /// Example: --format "{time} - [{duration}] - {directory}$\t{command}"
+ #[arg(long, short)]
+ format: Option<String>,
}
impl Cmd {
@@ -97,6 +102,7 @@ impl Cmd {
self.exit,
self.exclude_exit,
self.exclude_cwd,
+ self.format,
self.before,
self.after,
self.limit,
@@ -122,6 +128,7 @@ async fn run_non_interactive(
exit: Option<i64>,
exclude_exit: Option<i64>,
exclude_cwd: Option<String>,
+ format: Option<String>,
before: Option<String>,
after: Option<String>,
limit: Option<i64>,
@@ -202,6 +209,6 @@ async fn run_non_interactive(
.map(std::borrow::ToOwned::to_owned)
.collect();
- super::history::print_list(&results, list_mode);
+ super::history::print_list(&results, list_mode, format.as_deref());
Ok(results.len())
}