Take exception to exceptions to handle argparser errors and help
This commit is contained in:
parent
2741ff5a27
commit
075905f7ea
2 changed files with 18 additions and 4 deletions
|
@ -133,7 +133,8 @@ void sendSysexSettings();
|
|||
void sendSysexMessage(const char* messageCode);
|
||||
void sendSysexVersion();
|
||||
|
||||
void handleSysex(uint8_t *data, uint8_t length);
|
||||
void handleSysex(const uint8_t *data, uint8_t length);
|
||||
void handleSysexChunk(const uint8_t *data, uint16_t length, bool last);
|
||||
uint32_t crc32(uint8_t *message, size_t length);
|
||||
|
||||
void configInitScreen();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <functional>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
|
@ -16,6 +17,7 @@
|
|||
|
||||
#include <Arduino.h>
|
||||
|
||||
#define ARGS_NOEXCEPT
|
||||
#include "args.hxx"
|
||||
|
||||
// Forward declarations
|
||||
|
@ -622,10 +624,10 @@ static void SimQuit()
|
|||
int main(int argc, const char** argv)
|
||||
{
|
||||
|
||||
args::ArgumentParser parser("This is a test program.", "This goes after the options.");
|
||||
args::ArgumentParser parser("NuEVI simulator.");
|
||||
|
||||
|
||||
args::ValueFlag<std::string> eepromFile(parser, "eeprom-write", "File to use for EEPROM data", {'e', "eeprom-file"});
|
||||
args::HelpFlag help(parser, "help", "Display this help menu", {'h', "help"});
|
||||
args::ValueFlag<std::string> eepromFile(parser, "filename", "File to use for EEPROM data", {'e', "eeprom-file"});
|
||||
args::Flag eepromWrite(parser, "eeprom-write", "Write EEPROM changes to file", {'w', "eeprom-write"});
|
||||
args::Flag factoryReset(parser, "factory-reset", "Trigger factory reset", {'r', "factory-reset"});
|
||||
args::Flag configMode(parser, "config-mode", "Trigger config-management mode", {'c', "config-mode"});
|
||||
|
@ -633,6 +635,17 @@ int main(int argc, const char** argv)
|
|||
|
||||
parser.ParseCLI(argc, argv);
|
||||
|
||||
if(parser.GetError() != args::Error::None) {
|
||||
|
||||
if(parser.GetError() == args::Error::Help) {
|
||||
std::cout << parser << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::cerr << parser.GetErrorMsg() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string eepromFileName = args::get(eepromFile);
|
||||
|
||||
//Use a default EEPROM file if none is provided.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue