Merge branch 'refactoring' into dev

This commit is contained in:
tangxifan 2020-01-22 17:21:21 -07:00
commit 6309ef2db4
3 changed files with 26 additions and 8 deletions

View File

@ -17,6 +17,12 @@ void print_command_options(const Command& cmd) {
VTR_LOG("Command '%s' usage:\n%lu options available\n",
cmd.name().c_str(), cmd.options().size());
for (const CommandOptionId& opt : cmd.options()) {
if (true == cmd.option_short_name(opt).empty()) {
VTR_LOG("\t--%s : %s\n",
cmd.option_name(opt).c_str(),
cmd.option_description(opt).c_str());
continue;
}
VTR_LOG("\t--%s, -%s : %s\n",
cmd.option_name(opt).c_str(),
cmd.option_short_name(opt).c_str(),
@ -31,13 +37,18 @@ void print_command_options(const Command& cmd) {
********************************************************************/
void print_command_context(const Command& cmd,
const CommandContext& cmd_context) {
VTR_LOG("Confirm selected options when call command '%s':\n",
VTR_LOG("\nConfirm selected options when call command '%s':\n",
cmd.name().c_str());
for (const CommandOptionId& opt : cmd.options()) {
VTR_LOG("--%s",
cmd.option_name(opt).c_str());
if (false == cmd.option_short_name(opt).empty()) {
VTR_LOG(", -%s",
cmd.option_short_name(opt).c_str());
}
if (false == cmd.option_require_value(opt)) {
VTR_LOG("--%s, -%s : %s\n",
cmd.option_name(opt).c_str(),
cmd.option_short_name(opt).c_str(),
VTR_LOG(": %s\n",
cmd_context.option_enable(cmd, opt) ? "on" : "off");
} else {
VTR_ASSERT_SAFE (true == cmd.option_require_value(opt));
@ -48,9 +59,7 @@ void print_command_context(const Command& cmd,
} else {
opt_value = cmd_context.option_value(cmd, opt);
}
VTR_LOG("--%s, -%s : %s\n",
cmd.option_name(opt).c_str(),
cmd.option_short_name(opt).c_str(),
VTR_LOG(": %s\n",
opt_value.c_str());
}
}

View File

@ -312,7 +312,7 @@ void Shell<T>::print_commands() const {
template <class T>
void Shell<T>::exit() const {
VTR_LOG("Thank you for using %s!\n",
VTR_LOG("\nThank you for using %s!\n",
name().c_str());
std::exit(0);
}

View File

@ -0,0 +1,9 @@
# Call the help desk
help
# Set a value to the internal variable
set --value 5
print # Print out the value
exit # Finish