1 use super::InteractiveShell;
2 use ion_shell::expansion::Expander;
3 
4 impl<'a> InteractiveShell<'a> {
5     /// Generates the prompt that will be used by Liner.
prompt(&self) -> String6     pub fn prompt(&self) -> String {
7         let mut shell = self.shell.borrow_mut();
8         let blocks = if self.terminated.get() { shell.block_len() } else { shell.block_len() + 1 };
9 
10         if blocks == 0 {
11             shell.command("PROMPT").map(|res| res.to_string()).unwrap_or_else(|_| {
12                 let prompt = shell.variables().get_str("PROMPT").unwrap_or_default();
13                 match shell.get_string(&prompt) {
14                     Ok(prompt) => prompt.to_string(),
15                     Err(why) => {
16                         eprintln!("ion: prompt expansion failed: {}", why);
17                         ">>> ".into()
18                     }
19                 }
20             })
21         } else {
22             "    ".repeat(blocks)
23         }
24     }
25 }
26