diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-07-15 00:04:00 +0300 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-07-15 00:12:01 +0300 |
commit | f13da6a26a64f8cf29de161bb50dbf396696e094 (patch) | |
tree | cddbf20cc9e95fe5f7d4f24da122fe89cfb1db64 /ui/src/execute.rs | |
parent | f3d019f7ed1acdb65985e55e0315f6dba7978275 (diff) |
ui: Add pipe action for Pager
Diffstat (limited to 'ui/src/execute.rs')
-rw-r--r-- | ui/src/execute.rs | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/ui/src/execute.rs b/ui/src/execute.rs index 7008064a..a7833415 100644 --- a/ui/src/execute.rs +++ b/ui/src/execute.rs @@ -28,6 +28,7 @@ pub mod actions; pub use crate::actions::Action::{self, *}; pub use crate::actions::ListingAction::{self, *}; pub use crate::actions::MailingListAction::{self, *}; +pub use crate::actions::PagerAction::{self, *}; pub use crate::actions::TabAction::{self, *}; /* Create a const table with every command part that can be auto-completed and its description */ @@ -161,6 +162,29 @@ define_commands!([ ) ); ) + }, + /* Pipe pager contents to binary */ + { tags: ["pipe "], + desc: "pipe EXECUTABLE ARGS", + parser:( + named!( pipe<Action>, + alt_complete!( + do_parse!( + ws!(tag!("pipe")) + >> bin: map_res!(is_not!(" "), std::str::from_utf8) + >> is_a!(" ") + >> args: separated_list!(is_a!(" "), is_not!(" ")) + >> ({ + Pager(Pipe(bin.to_string(), args.into_iter().map(|v| String::from_utf8(v.to_vec()).unwrap()).collect::<Vec<String>>())) + })) | do_parse!( + ws!(tag!("pipe")) + >> bin: ws!(map_res!(is_not!(" "), std::str::from_utf8)) + >> ({ + Pager(Pipe(bin.to_string(), Vec::new())) + }) + )) + ); + ) } ]); @@ -207,5 +231,5 @@ named!( alt_complete!(toggle | envelope_action | filter | toggle_thread_snooze) ); named!(pub parse_command<Action>, - alt_complete!( goto | listing_action | sort | subsort | close | mailinglist | setenv | printenv) + alt_complete!( goto | listing_action | sort | subsort | close | mailinglist | setenv | printenv | pipe) ); |