forked from Orchid/orchid
in midst of refactor
This commit is contained in:
2
orchidlang/src/bin/cli/mod.rs
Normal file
2
orchidlang/src/bin/cli/mod.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
mod prompt;
|
||||
pub use prompt::cmd_prompt;
|
||||
11
orchidlang/src/bin/cli/prompt.rs
Normal file
11
orchidlang/src/bin/cli/prompt.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
use std::io::{self, Error, Write};
|
||||
|
||||
pub fn cmd_prompt(prompt: &str) -> Result<(String, Vec<String>), Error> {
|
||||
print!("{}", prompt);
|
||||
io::stdout().flush()?;
|
||||
let mut cmdln = String::new();
|
||||
io::stdin().read_line(&mut cmdln)?;
|
||||
let mut segments = cmdln.split(' ');
|
||||
let cmd = if let Some(cmd) = segments.next() { cmd } else { "" };
|
||||
Ok((cmd.to_string(), segments.map(str::to_string).collect()))
|
||||
}
|
||||
Reference in New Issue
Block a user