diff options
| author | Jacob Palecki <[email protected]> | 2020-08-11 21:16:50 -0700 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2020-08-11 21:16:50 -0700 |
| commit | 319eb45dee5b805eee976d7c2d6be0a9d090d3ed (patch) | |
| tree | d164cf52ce420c2c51aee2e9c0fe67c5fe5b56c5 /console | |
| parent | Further comments (diff) | |
| parent | Merge pull request #13 from a1xd/write-cd (diff) | |
| download | rawaccel-319eb45dee5b805eee976d7c2d6be0a9d090d3ed.tar.xz rawaccel-319eb45dee5b805eee976d7c2d6be0a9d090d3ed.zip | |
Merge branch 'master' into GainCap
Diffstat (limited to 'console')
| -rw-r--r-- | console/console.cpp | 10 | ||||
| -rw-r--r-- | console/parse.hpp | 8 |
2 files changed, 7 insertions, 11 deletions
diff --git a/console/console.cpp b/console/console.cpp index 9a1d66f..f86dfc2 100644 --- a/console/console.cpp +++ b/console/console.cpp @@ -10,12 +10,10 @@ int main(int argc, char** argv) { try { ra::write(ra::parse(argc, argv)); } - catch (std::domain_error e) { - std::cerr << e.what() << '\n'; - return ra::INVALID_ARGUMENT; + catch (const std::system_error& e) { + std::cerr << e.what() << " (" << e.code() << ")\n"; } - catch (std::system_error e) { - std::cerr << "Error: " << e.what() << " (" << e.code() << ")\n"; - return ra::SYSTEM_ERROR; + catch (const std::exception& e) { + std::cerr << e.what() << '\n'; } } diff --git a/console/parse.hpp b/console/parse.hpp index 1cdb3fb..abdd36c 100644 --- a/console/parse.hpp +++ b/console/parse.hpp @@ -3,16 +3,12 @@ #include <iostream> #include <rawaccel.hpp> -#include <accel-error.hpp> +#include <rawaccel-error.hpp> #include "external/clipp.h" namespace rawaccel { - inline constexpr int SYSTEM_ERROR = -1; - inline constexpr int PARSE_ERROR = 1; - inline constexpr int INVALID_ARGUMENT = 2; - template<typename Accel, typename StrFirst, typename... StrRest> clipp::parameter make_accel_cmd(modifier_args& args, StrFirst&& first_flag, StrRest&&... rest) { return clipp::command(first_flag, rest...) @@ -113,6 +109,8 @@ namespace rawaccel { ); if (!clipp::parse(argc, argv, cli)) { + constexpr int PARSE_ERROR = 1; + std::cout << clipp::usage_lines(cli, "rawaccel", make_doc_fmt()); std::exit(PARSE_ERROR); } |