-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Add AllowRepeats to SBCommandInterpreterRunOptions. #94786
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,15 +93,20 @@ class CommandInterpreterRunOptions { | |
/// \param[in] add_to_history | ||
/// If \b true add the commands to the command history. If \b false, don't | ||
/// add them. | ||
/// \param[in] handle_repeats | ||
/// If \b true then treat empty lines as repeat commands even if the | ||
/// interpreter is non-interactive. | ||
CommandInterpreterRunOptions(LazyBool stop_on_continue, | ||
LazyBool stop_on_error, LazyBool stop_on_crash, | ||
LazyBool echo_commands, LazyBool echo_comments, | ||
LazyBool print_results, LazyBool print_errors, | ||
LazyBool add_to_history) | ||
LazyBool add_to_history, | ||
LazyBool handle_repeats) | ||
: m_stop_on_continue(stop_on_continue), m_stop_on_error(stop_on_error), | ||
m_stop_on_crash(stop_on_crash), m_echo_commands(echo_commands), | ||
m_echo_comment_commands(echo_comments), m_print_results(print_results), | ||
m_print_errors(print_errors), m_add_to_history(add_to_history) {} | ||
m_print_errors(print_errors), m_add_to_history(add_to_history), | ||
m_allow_repeats(handle_repeats) {} | ||
|
||
CommandInterpreterRunOptions() = default; | ||
|
||
|
@@ -182,6 +187,11 @@ class CommandInterpreterRunOptions { | |
void SetSpawnThread(bool spawn_thread) { | ||
m_spawn_thread = spawn_thread ? eLazyBoolYes : eLazyBoolNo; | ||
} | ||
bool GetAllowRepeats() const { return DefaultToNo(m_allow_repeats); } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: newline between There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
void SetAllowRepeats(bool allow_repeats) { | ||
m_allow_repeats = allow_repeats ? eLazyBoolYes : eLazyBoolNo; | ||
} | ||
|
||
LazyBool m_stop_on_continue = eLazyBoolCalculate; | ||
LazyBool m_stop_on_error = eLazyBoolCalculate; | ||
|
@@ -193,6 +203,7 @@ class CommandInterpreterRunOptions { | |
LazyBool m_add_to_history = eLazyBoolCalculate; | ||
LazyBool m_auto_handle_events; | ||
LazyBool m_spawn_thread; | ||
LazyBool m_allow_repeats = eLazyBoolCalculate; | ||
|
||
private: | ||
static bool DefaultToYes(LazyBool flag) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2707,7 +2707,8 @@ enum { | |
eHandleCommandFlagEchoCommentCommand = (1u << 3), | ||
eHandleCommandFlagPrintResult = (1u << 4), | ||
eHandleCommandFlagPrintErrors = (1u << 5), | ||
eHandleCommandFlagStopOnCrash = (1u << 6) | ||
eHandleCommandFlagStopOnCrash = (1u << 6), | ||
eHandleCommandFlagAllowRepeats = (1u << 7) | ||
}; | ||
|
||
void CommandInterpreter::HandleCommandsFromFile( | ||
|
@@ -3129,14 +3130,19 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler, | |
return; | ||
|
||
const bool is_interactive = io_handler.GetIsInteractive(); | ||
if (!is_interactive) { | ||
bool allow_repeats = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
io_handler.GetFlags().Test(eHandleCommandFlagAllowRepeats); | ||
|
||
if (!is_interactive && !allow_repeats) { | ||
// When we are not interactive, don't execute blank lines. This will happen | ||
// sourcing a commands file. We don't want blank lines to repeat the | ||
// previous command and cause any errors to occur (like redefining an | ||
// alias, get an error and stop parsing the commands file). | ||
// But obey the AllowRepeats flag if the user has set it. | ||
if (line.empty()) | ||
return; | ||
|
||
} | ||
if (!is_interactive) { | ||
// When using a non-interactive file handle (like when sourcing commands | ||
// from a file) we need to echo the command out so we don't just see the | ||
// command output and no command... | ||
|
@@ -3388,6 +3394,8 @@ CommandInterpreter::GetIOHandler(bool force_create, | |
flags |= eHandleCommandFlagPrintResult; | ||
if (options->m_print_errors != eLazyBoolNo) | ||
flags |= eHandleCommandFlagPrintErrors; | ||
if (options->m_allow_repeats == eLazyBoolYes) | ||
flags |= eHandleCommandFlagAllowRepeats; | ||
} else { | ||
flags = eHandleCommandFlagEchoCommand | eHandleCommandFlagPrintResult | | ||
eHandleCommandFlagPrintErrors; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be
///
so they get picked up by Doxygen.