Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added exit command to debugger #267

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/debugger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,26 @@ impl DebuggerCommand for ContinueCommand {
}
}

struct ExitCommand;
#[derive(Parser, Debug)]
enum ExitSubcommand {
/// Exits the debugger and shutsdown the simulation
Exit,
}
impl DebuggerCommand for ExitCommand {
fn handle(
&self,
context: &mut Context,
_matches: &ArgMatches,
) -> Result<(bool, Option<String>), String> {
context.shutdown();
Ok((true, None))
}
fn extend(&self, command: Command) -> Command {
ExitSubcommand::augment_subcommands(command)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this PR for a debugger command to exit cleanly or terminate the process as with ctrl+D?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'exit' command will shutdown the simulation (exit nicely).
vs Ctrl-D, that will kill the process without shutdown.

}
}

// Build the debugger context.
fn init(context: &mut Context) {
let debugger = context.get_data_container_mut(DebuggerPlugin);
Expand All @@ -209,6 +229,7 @@ fn init(context: &mut Context) {
commands.insert("population", Box::new(PopulationCommand));
commands.insert("next", Box::new(NextCommand));
commands.insert("continue", Box::new(ContinueCommand));
commands.insert("exit", Box::new(ExitCommand));
commands.insert("global", Box::new(GlobalPropertyCommand));

let mut cli = Command::new("repl")
Expand All @@ -232,7 +253,7 @@ fn init(context: &mut Context) {
}

fn exit_debugger() -> ! {
println!("Got Ctrl-D, Exiting...");
println!("Got Ctrl-D, Terminating execution.");
std::process::exit(0);
}

Expand Down