From af38b1306a6ea0bc4a9ef3229581bfdfdcd3fc79 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Thu, 6 Feb 2020 01:51:50 +0200 Subject: [PATCH] ui: use quoted_argument parser in Ex command arguments --- src/execute.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/execute.rs b/src/execute.rs index aeb8fc7c..454408e2 100644 --- a/src/execute.rs +++ b/src/execute.rs @@ -197,14 +197,14 @@ define_commands!([ alt_complete!( do_parse!( ws!(tag!("pipe")) - >> bin: map_res!(is_not!(" "), std::str::from_utf8) + >> bin: quoted_argument >> is_a!(" ") >> args: separated_list!(is_a!(" "), quoted_argument) >> ({ View(Pipe(bin.to_string(), args.into_iter().map(String::from).collect::>())) })) | do_parse!( ws!(tag!("pipe")) - >> bin: ws!(map_res!(is_not!(" "), std::str::from_utf8)) + >> bin: ws!(quoted_argument) >> ({ View(Pipe(bin.to_string(), Vec::new())) }) @@ -218,7 +218,7 @@ define_commands!([ named!( add_attachment, do_parse!( ws!(tag!("add-attachment")) - >> path: map_res!(call!(not_line_ending), std::str::from_utf8) + >> path: quoted_argument >> (Compose(AddAttachment(path.to_string()))) ) ); @@ -230,7 +230,7 @@ define_commands!([ named!( remove_attachment, do_parse!( ws!(tag!("remove-attachment")) - >> idx: map_res!(map_res!(call!(not_line_ending), std::str::from_utf8), usize::from_str) + >> idx: map_res!(quoted_argument, usize::from_str) >> (Compose(RemoveAttachment(idx))) ) ); @@ -348,7 +348,7 @@ define_commands!([ named!( save_attachment, do_parse!( ws!(tag!("save-attachment")) - >> idx: map_res!(map_res!(is_not!(" "), std::str::from_utf8), usize::from_str) + >> idx: map_res!(quoted_argument, usize::from_str) >> path: ws!(quoted_argument) >> (View(SaveAttachment(idx, path.to_string()))) ) @@ -365,11 +365,11 @@ define_commands!([ alt_complete!( do_parse!( ws!(tag!("add")) - >> tag: ws!(map_res!(call!(not_line_ending), std::str::from_utf8)) + >> tag: ws!(quoted_argument) >> (Listing(Tag(Add(tag.to_string()))))) | do_parse!( ws!(tag!("remove")) - >> tag: ws!(map_res!(call!(not_line_ending), std::str::from_utf8)) + >> tag: ws!(quoted_argument) >> (Listing(Tag(Remove(tag.to_string()))))) )