GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — RustPython/src/shell.rs at main · RustPython/RustPython

Expand file tree

/

shell.rs

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
41 lines (39 loc) · 1.33 KB
/

shell.rs

Copy path

File metadata and controls

41 lines (39 loc) · 1.33 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
mod helper;
use rustpython_vm::{
PyResult, VirtualMachine,
readline::{Readline, ReadlineResult},
scope::Scope,
vm::InteractiveLine,
};
/// Enter a repl loop
///
/// rustyline takes the role of `PyOS_Readline` with the readline module,
/// adding line editing, completion and history.
pub fn run_shell(vm: &VirtualMachine, scope: Scope) -> PyResult<()> {
let mut repl = Readline::new(helper::ShellHelper::new(vm, scope.globals));
let history = dirs::config_dir().map_or_else(
|| ".repl_history.txt".into(),
|mut path| {
path.push("rustpython");
path.push("repl_history.txt");
path
},
);
let _ = repl.load_history(&history);
let result = vm.run_interactive_loop(|prompt| match repl.readline(prompt) {
ReadlineResult::Line(line) => {
let _ = repl.add_history_entry(line.trim_end());
Ok(Some(InteractiveLine::Text(line)))
}
ReadlineResult::Eof => Ok(None),
ReadlineResult::Interrupt => {
Err(vm.new_exception_empty(vm.ctx.exceptions.keyboard_interrupt.to_owned()))
}
ReadlineResult::Io(_) => Ok(None),
#[cfg(unix)]
ReadlineResult::OsError(_) => Ok(None),
ReadlineResult::Other(_) => Ok(None),
});
let _ = repl.save_history(&history);
result
}
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.