From eb09f9a5d1b1d9fb1dde76ae83749bcccb043c7a Mon Sep 17 00:00:00 2001 From: Emily Toop Date: Thu, 29 Jun 2017 13:35:09 -0700 Subject: [PATCH] Simply no argument parsing --- tools/cli/src/mentat_cli/command_parser.rs | 44 ++++++---------------- 1 file changed, 12 insertions(+), 32 deletions(-) diff --git a/tools/cli/src/mentat_cli/command_parser.rs b/tools/cli/src/mentat_cli/command_parser.rs index 131117bf..31089ba9 100644 --- a/tools/cli/src/mentat_cli/command_parser.rs +++ b/tools/cli/src/mentat_cli/command_parser.rs @@ -128,46 +128,26 @@ pub fn command(s: &str) -> Result { } Ok(Command::Open(args[0].clone())) }); - - let no_arg_parser = || arguments() - .skip(spaces()) - .skip(eof()); let close_parser = string(CLOSE_COMMAND) - .with(no_arg_parser()) - .map(|args| { - if !args.is_empty() { - bail!(cli::ErrorKind::CommandParse(format!("Unrecognized argument {:?}", args[0])) ); - } - Ok(Command::Close) - }); + .skip(spaces()) + .skip(eof()) + .map(|_| Ok(Command::Close) ); let schema_parser = string(SCHEMA_COMMAND) - .with(no_arg_parser()) - .map(|args| { - if !args.is_empty() { - bail!(cli::ErrorKind::CommandParse(format!("Unrecognized argument {:?}", args[0])) ); - } - Ok(Command::Schema) - }); + .skip(spaces()) + .skip(eof()) + .map(|_| Ok(Command::Schema)); let attributes_parser = string(ATTRIBUTES_COMMAND) - .with(no_arg_parser()) - .map(|args| { - if !args.is_empty() { - bail!(cli::ErrorKind::CommandParse(format!("Unrecognized argument {:?}", args[0])) ); - } - Ok(Command::Attributes) - }); + .skip(spaces()) + .skip(eof()) + .map(|_| Ok(Command::Attributes)); let exit_parser = try(string(LONG_EXIT_COMMAND)).or(try(string(SHORT_EXIT_COMMAND))) - .with(no_arg_parser()) - .map(|args| { - if !args.is_empty() { - bail!(cli::ErrorKind::CommandParse(format!("Unrecognized argument {:?}", args[0])) ); - } - Ok(Command::Exit) - }); + .skip(spaces()) + .skip(eof()) + .map(|_| Ok(Command::Exit) ); let edn_arg_parser = || spaces() .with(look_ahead(string("[").or(string("{")))