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

Add version command #30

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
16 changes: 16 additions & 0 deletions c6021light/src/ConsoleManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ DEFINE_COMMAND_STRING(flash);
DEFINE_COMMAND_STRING(dump);
DEFINE_COMMAND_STRING(save);
DEFINE_COMMAND_STRING(format);

DEFINE_COMMAND_STRING(version);
DEFINE_COMMAND_STRING(help);

static constexpr const char* turnoutProtocolHelp{
Expand All @@ -60,6 +62,7 @@ int run_app_set_turnout_protocol(int argc, const char* const* argv, int argcMatc
int run_app_get_turnout_protocol(int argc, const char* const* argv, int argcMatched);
int run_app_save(int argc, const char* const* argv, int argcMatched);
int run_app_help(int argc, const char* const* argv, int argcMatched);
int run_app_version(int argc, const char* const* argv, int argcMatched);
int run_app_dump_flash(int argc, const char* const* argv,
int argcMatched); // implemented in eeprom emulation
int run_app_format_flash(int argc, const char* const* argv,
Expand Down Expand Up @@ -142,6 +145,7 @@ static const cliSupport::Argument argtable[] = {
"Control the LocoNet Refresh Slot server."},
{COMMAND(canEngineDB), COMMAND_ARGS(canEngineDB), nullptr, "Control the Can Engine DB."},
{COMMAND(help), nullptr, run_app_help, "Display this help message."},
{COMMAND(version), nullptr, run_app_version, "Display version information."},
{}};
} // namespace

Expand Down Expand Up @@ -189,6 +193,11 @@ int run_app_help(int, const char* const*, int) {
return 0;
}

int run_app_version(int, const char* const*, int) {
display_version(0, nullptr);
return 0;
}

namespace {
void printArguments(int argc, const char* const* argv) {
for (int i = 0; i < argc; ++i) {
Expand Down Expand Up @@ -231,6 +240,13 @@ void display_help(int argc, const char* const* argv) {
}
}

void display_version(int, const char* const*) {
puts("Current Version:");
puts("fd469d610a70e3e384686cecfb074ee3d4c389b5");
printf("\n");
}


void begin(DataModel* dataModel) {
dataModel_ = dataModel;

Expand Down
1 change: 1 addition & 0 deletions c6021light/src/ConsoleManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ extern microrl_t microrl;
void begin(DataModel* dataModel);

void display_help(int argc, const char* const* argv);
void display_version(int argc, const char* const* argv);

/**
* \brief Verify that the expected (range of) number(s) of arguments is available.
Expand Down
Loading